AssetList(again)

Posted By: leohermoso

AssetList(again) - 01/28/20 22:04

I am struggling with something that supposed to be simple, the creation of my asset list.

I took advantage of
Quote
#define EXAMINE


inside the MT4/5 plugin to generate and check the list. Well even using the exact same values, zorro complains about MarginCost. In the asset list MarginCost is set to 0(zero)

Quote

2020.01.28 19:00:03.468 Zorro (EURUSD,H1) Examine XTIUSD Price 54.03000 Spread 0.11000
2020.01.28 19:00:03.468 Zorro (EURUSD,H1) XTIUSD Point 0.01000 Digits 2 PIP 0.01000
2020.01.28 19:00:03.468 Zorro (EURUSD,H1) XTIUSD LotMin 0.01 LotSize 100.00 LotAmount 1.00
2020.01.28 19:00:03.468 Zorro (EURUSD,H1) XTIUSD PipCost 0.01000 MarginCost 5.00


So my AssetList for pepperstone should be something like this:

Code
Name	Price	Spread	RollLong	RollShort	PIP	PIPCost	MarginCost	Leverage	LotAmount	Commission	Symbol
AUD/CAD	0,90919	0,00009	-2,21	-0,83	0,0001	0,076017	0	500	1000	0	AUD/CAD
AUD/JPY	76,06	0,002	2,27	-4,77	0,01	0,091612	0	500	1000	0	AUD/JPY
AUD/NZD	1,0442	0,00007	-1,75	-2,02	0,0001	0,065468	0	500	1000	0	AUD/NZD
AUD/USD	0,69974	0,00004	-2,62	-1,97	0,0001	0,1	0	500	1000	0	AUD/USD
AUS200	6747,9	3,8	-3,31	-1,69	0,1	0,006763	0	500	0,1	0	AUS200
CAD/JPY	83,67	0,016	2,94	-6,04	0,01	0,091612	0	500	1000	0	CAD/JPY
EUR/AUD	1,60037	0,00005	-11,45	6,68	0,0001	0,067628	0	500	1000	0	EUR/AUD
EUR/CAD	1,4549	0,00004	-11,86	6,55	0,0001	0,076017	0	500	1000	0	EUR/CAD
EUR/CHF	1,08651	0,00005	-1,15	-2,58	0,0001	0,102769	0	500	1000	0	EUR/CHF
EUR/GBP	0,8498	0,00007	-5,34	0,5	0,0001	0,13026	0	500	1000	0	EUR/GBP
EUR/JPY	121,71	0,003	-3,16	-1,05	0,01	0,091612	0	500	1000	0	EUR/JPY
EUR/NZD	1,67089	0,00015	-11,86	5,77	0,0001	0,065468	0	500	1000	0	EUR/NZD
EUR/USD	1,11967	0,00003	-8,57	4,46	0,0001	0,1	0	500	1000	0	EUR/USD
GBP/AUD	1,88347	0,00016	-8,52	0,13	0,0001	0,067628	0	500	1000	0	GBP/AUD
GBP/CAD	1,71224	0,00008	-9,6	0,63	0,0001	0,076017	0	500	1000	0	GBP/CAD
GBP/CHF	1,27868	0,00016	1,76	-8,64	0,0001	0,102769	0	500	1000	0	GBP/CHF
GBP/JPY	143,24	0,009	-0,14	-7,5	0,01	0,091612	0	500	1000	0	GBP/JPY
GBP/NZD	1,96645	0,00032	-8,94	-1,53	0,0001	0,065468	0	500	1000	0	GBP/NZD
GBP/USD	1,31775	0,00006	-6,79	-0,04	0,0001	0,1	0	500	1000	0	GBP/USD
GER30	13371,35	5	-2	-3	0,1	0,011022	0	500	0,1	0	GER30
JPN225	23761,5	20	-2,41	-2,59	0,1	0,009161	0	500	10	0	JPN225
NZD/CAD	0,87096	0,00019	-2,4	-0,45	0,0001	0,076017	0	500	1000	0	NZD/CAD
NZD/JPY	72,85	0,006	1,8	-4,46	0,01	0,091612	0	500	1000	0	NZD/JPY
NZD/USD	0,67025	0,00006	-2,14	-1,17	0,0001	0,1	0	500	1000	0	NZD/USD
UK100	7615,25	4	-3,15	-1,85	0,1	0,013026	0	500	0,1	0	UK100
USD/CAD	1,29943	0,00001	-2,9	-1,93	0,0001	0,076017	0	500	1000	0	USD/CAD
USD/CHF	0,97038	0,00005	4,56	-8,18	0,0001	0,102769	0	500	1000	0	USD/CHF
USD/JPY	108,7	0,004	2,92	-8,2	0,01	0,091612	0	500	1000	0	USD/JPY
XAG/USD	18,1	0,011	-1,41	0,47	0,01	0,5	0	500	50	0	XAG/USD
XAU/USD	1528,3	0,15	-10,85	4,57	0,01	0,01	0	500	1	0	XAU/USD



Yet, when I start zorro connecting to MT4 the asset.csv created on log folder comes with a complete nonsense Leverage Values and still zero for MarginCost

This is what I got.

Code
Name	Price	Spread	RollLong	RollShort	PIP	PIPCost	MarginCost	Leverage	LotAmount	Commission	Symbol
AUD/CAD	0,90919	0,00009	-2,21	-0,83	0,0001	0,076017	0	0,676	1000	0	AUD/CAD
AUD/JPY	76,06	0,002	2,27	-4,77	0,01	0,091612	0	0,676	1000	0	AUD/JPY
AUD/NZD	1,0442	0,00007	-1,75	-2,02	0,0001	0,065468	0	0,676	1000	0	AUD/NZD
AUD/USD	0,69974	0,00004	-2,62	-1,97	0,0001	0,1	0	0,676	1000	0	AUD/USD
AUS200	6747,9	3,8	-3,31	-1,69	0,1	0,006763	0	300	0,1	0	AUS200
CAD/JPY	83,67	0,016	2,94	-6,04	0,01	0,091612	0	0,76	1000	0	CAD/JPY
EUR/AUD	1,60037	0,00005	-11,45	6,68	0,0001	0,067628	0	1,102	1000	0	EUR/AUD
EUR/CAD	1,4549	0,00004	-11,86	6,55	0,0001	0,076017	0	1,102	1000	0	EUR/CAD
EUR/CHF	1,08651	0,00005	-1,15	-2,58	0,0001	0,102769	0	1,102	1000	0	EUR/CHF
EUR/GBP	0,8498	0,00007	-5,34	0,5	0,0001	0,13026	0	1,102	1000	0	EUR/GBP
EUR/JPY	121,71	0,003	-3,16	-1,05	0,01	0,091612	0	1,102	1000	0	EUR/JPY
EUR/NZD	1,67089	0,00015	-11,86	5,77	0,0001	0,065468	0	1,102	1000	0	EUR/NZD
EUR/USD	1,11967	0,00003	-8,57	4,46	0,0001	0,1	0	1,102	1000	0	EUR/USD
GBP/AUD	1,88347	0,00016	-8,52	0,13	0,0001	0,067628	0	1,303	1000	0	GBP/AUD
GBP/CAD	1,71224	0,00008	-9,6	0,63	0,0001	0,076017	0	1,303	1000	0	GBP/CAD
GBP/CHF	1,27868	0,00016	1,76	-8,64	0,0001	0,102769	0	1,303	1000	0	GBP/CHF
GBP/JPY	143,24	0,009	-0,14	-7,5	0,01	0,091612	0	1,303	1000	0	GBP/JPY
GBP/NZD	1,96645	0,00032	-8,94	-1,53	0,0001	0,065468	0	1,303	1000	0	GBP/NZD
GBP/USD	1,31775	0,00006	-6,79	-0,04	0,0001	0,1	0	1,303	1000	0	GBP/USD
GER30	13371,35	5	-2	-3	0,1	0,011022	0	300	0,1	0	GER30
JPN225	23761,5	20	-2,41	-2,59	0,1	0,009161	0	300	10	0	JPN225
NZD/CAD	0,87096	0,00019	-2,4	-0,45	0,0001	0,076017	0	0,655	1000	0	NZD/CAD
NZD/JPY	72,85	0,006	1,8	-4,46	0,01	0,091612	0	0,655	1000	0	NZD/JPY
NZD/USD	0,67025	0,00006	-2,14	-1,17	0,0001	0,1	0	0,655	1000	0	NZD/USD
UK100	7615,25	4	-3,15	-1,85	0,1	0,013026	0	300	0,1	0	UK100
USD/CAD	1,29943	0,00001	-2,9	-1,93	0,0001	0,076017	0	1	1000	0	USD/CAD
USD/CHF	0,97038	0,00005	4,56	-8,18	0,0001	0,102769	0	1	1000	0	USD/CHF
USD/JPY	108,7	0,004	2,92	-8,2	0,01	0,091612	0	1	1000	0	USD/JPY
XAG/USD	18,1	0,011	-1,41	0,47	0,01	0,5	0	17,489	50	0	XAG/USD
XAU/USD	1528,3	0,15	-10,85	4,57	0,01	0,01	0	1568,2	1	0	XAU/USD



How should I trade with a 0,676 leverage? Can you please guys, give me some clarification on this?

Best Regards.

Leo Hermoso
Posted By: leohermoso

Re: AssetList(again) - 01/28/20 23:40

I did a fix

Code
brokerCommand(SET_PATCH, 16 + 32);
Leverage = 500;
Posted By: jcl

Re: AssetList(again) - 01/29/20 13:04

That's not a real fix. Better fix either the leverage, or the margin cost in your asset list. If your broker API does not provide these parameters, or returns nonsense, you must get them from the broker's website.
Posted By: leohermoso

Re: AssetList(again) - 01/29/20 14:36

jcl, tks for your reply!

That's exactly what I did. I used Spotware API and created a small python program to create the asset list.

For those search the list for pepperstone here it is.

Now in order to completely ignore data from broker should I use

Code
brokerCommand(SET_PATCH, 16 + 32 + 64);


Tks again

Attached File
AssetList.csv  (5 downloads)
Posted By: leohermoso

Re: AssetList(again) - 01/29/20 15:27

Even using this

Code
			brokerCommand(SET_PATCH, 16 + 32 + 64);
			printf("%f\n",MarginCost);


I still get a warning

Warning 054: EURUSD MarginCost 22-> 1000!

and the printed value for MarginCost is the one loaded for the server.

So what's the trick to make this brokerCommand(SET_PATCH, 16 + 32 + 64); works?
Posted By: AndrewAMD

Re: AssetList(again) - 01/29/20 16:16

The broker command must be issued before you load the assets so that it does not override your asset list settings.
Posted By: leohermoso

Re: AssetList(again) - 01/29/20 16:20

Tks Andrew!

Code
function run()
{
	brokerCommand(SET_PATCH, 16 + 32 + 64);
	assetList("History\\AssetListSimpleFx.csv");
	
	LookBack = 1;
	BarPeriod = 1440;
   
       StartDate = NOW;
	asset("EURUSD");	
	
	Margin = 4;
	enterLong();		
		
	
}


Can you please point where is the error in the code?

tks
Posted By: leohermoso

Re: AssetList(again) - 01/29/20 17:21

This

brokerCommand(SET_PATCH, 16 + 32 + 64);

can be marked as a bug(MT5), or you must provide a functional example on the manual.

Using the command or not, seems to have the same effect.

I followed the instructions in the manual( that, in this case, is absent) and also sent an email to support using a paid ticket, but this does not work.

Super frustrating.

Attached picture support opde.PNG
Posted By: leohermoso

Re: AssetList(again) - 01/29/20 22:09

The major problem is not the broker supplying wrong values, but the EA making some crazy calculations. I did a small modification on the EA(MT5 bridge) and now I can get the correct values.

Code
            double dLotFactor = MarketInfo(Asset,MODE_MINLOT); // correction for different lot scale
            double dFactor = pointFactor(Asset); // correction for brokers with 5 digits
            double pipPosition = MarketInfo(Asset,MODE_DIGITS) - 1;
            string quotecur = StringSubstr(Asset,3);
            double price = MarketInfo(Asset,MODE_ASK);
            double pip =  pow(10,-pipPosition);
            double lotamount =  MarketInfo(Asset,MODE_LOTSIZE) * dLotFactor;
            double pipcost = lotamount * pip;
            double leverage = AccountInfoInteger(ACCOUNT_LEVERAGE);
            double margincost = (lotamount * price);
            if(StringLen(Asset) == 6)
              {

               if(StringCompare(quotecur,"USD") != 0)
                 {
                  string symboconvert = "USD" + quotecur;
                  double price2;
                  bool is_custom=false;

                  if(SymbolExist(symboconvert,is_custom))
                    {
                     price2 = MarketInfo("USD" + quotecur,MODE_ASK);
                     is_custom = true;
                    }
                  else
                     if(SymbolExist(quotecur + "USD",is_custom))
                       {
                        price2 = MarketInfo(quotecur + "USD",MODE_ASK);
                        is_custom = true;
                       }
                  if(is_custom)
                    {
                     pipcost = pipcost / price2;
                     margincost = margincost / price2;
                    }

                 }
              }
            margincost = margincost / leverage;
            double rollLong  = MarketInfo(Asset,MODE_SWAPLONG) * pipcost ;
            double rollShort = MarketInfo(Asset,MODE_SWAPSHORT)* pipcost  ;

            /////////

            double LotFactor = MarketInfo(Asset,MODE_MINLOT); // correction for different lot scale

            Factor = pointFactor(Asset); // correction for brokers with 5 digits
            arr[3] = PIP = pip;
            arr[4] = PIPCost = pipcost;
            arr[5] = LotAmount = lotamount;
            if(LotAmount == 0. && arr[0] > 0.)
               Print("Asset ",Asset," Lot ",MarketInfo(Asset,MODE_LOTSIZE)," Min ",LotFactor);
            arr[6] = margincost;
            arr[7] = rollLong;
            arr[8] = rollShort;

            arr[9] = iVolume(Asset,PERIOD_M15,0)/15.;
            ZorroRespond(cmd,arr);
            break;
© 2024 lite-C Forums