Problem with lot size calculation when USD not base neither terms currency

 

PLease check this code I am using to calculate lot sizes for EURUSD:

double Lots=NormalizeDouble(AccountBalance()*Risk/100000/Digits/Trail_Stop/10,2);

it seems to work well because my Account Balance is in USD. So in this case, because USD is the terms currency it works well.


I use this other code for pairs like USDJPY where USD is the BASE currency:

double Lots=NormalizeDouble(AccountBalance()*Risk/100000/Digits/Trail_Stop/10,2);


but what can I do to calculate lot sizes when using different pair currencies, like EURGBP, EURJPY, CHFJPY,...where USD is not the terms neither the base currency?

By the way, I have read all former discussions about lot sizes and couldn´t find a direct answer to this question

best regards

 
Justhavingfun:

PLease check this code I am using to calculate lot sizes for EURUSD:

it seems to work well because my Account Balance is in USD. So in this case, because USD is the terms currency it works well.


I use this other code for pairs like USDJPY where USD is the BASE currency:


but what can I do to calculate lot sizes when using different pair currencies, like EURGBP, EURJPY, CHFJPY,...where USD is not the terms neither the base currency?

By the way, I have read all former discussions about lot sizes and couldn´t find a direct answer to this question

best regards


uupss, this is the code I am using when USD is the base currency:


double Lots=NormalizeDouble(AccountBalance()*Risk*Ask/100000/Digits/Trail_Stop/10,2);

 
Justhavingfun:

uupss, this is the code I am using when USD is the base currency:


please replace Digits for Points at the lots calculation, I made that change some time ago but forgoted to mention it.
 

Please don't flooding the forum by commenting your own topic.

Check MarketInfo's MODE_MARGINREQUIRED for the cost of opening 1 lot, and any other MarketInfo's identifier (https://docs.mql4.com/constants/marketinfo)

And there are plenty in the forum anyway https://www.mql4.com/search#!keyword=lot%20calculation&module=mql4_module_forum 

 
Justhavingfun:


By the way, I have read all former discussions about lot sizes and couldn´t find a direct answer to this question

No you haven't . . .

 

Read this,  but not just the first post:  https://www.mql5.com/en/forum/123914 

Reason: