Lot Size calculation By Dollar Value

 

Dear,

I need a simple MQL code that calculate lot size for profit selected amount in selected pips. example i want open a trade in EURUSD and set TP 5 pips want to profit  50$ then how i calculation how much lot i need to open.

Like

EURUSD=

1pips      profit 10$     lots size  1.00

5pips      profit 30$     Lot size    ?

Function would be like below

double  LotSize (string symbol, double pips,  double HowMuchDollow){

   // here the code

}
Thanks you
 

Try something like this:

double volume = Amount / (pips * MarketInfo(symbol, MODE_POINT) * MarketInfo(symbol, MODE_TICKVALUE) / MarketInfo(symbol, MODE_TICKSIZE));
 
Stanislav Korotky:

Try something like this:

Thanks it is working