kandasami:
Hi All,
I wanted my EA to auto calculate the lot sizing based on a fixed 2% on my account balance of ($100,000) against the stop loss I get the the ParabolicSar.
I am not sure what I did wrong here but my EA will not run unless i replace the "lot" variable to an actual lot size like "0.10".
Please do advise. Thank you.
Try my way:
if(Long==true&&BuyOrders<1){ SL=0;if(StopLoss==true){SL=(Ask-SAR[0])/_Point;} double LotSize=MathRound((Risk*((Balance/SL)/Tick)/100)/minLot)*minLot; if(!trade.PositionOpen(_Symbol,ORDER_TYPE_BUY,LotSize,Ask,SAR[0],Ask+(SL*5)*_Point,CustomComment)){ Print("PositionOpen error ",trade.ResultRetcode()); return; } } if(Short==true&&SellOrders<1){ SL=0;if(StopLoss==true){SL=(SAR[0]-Bid)/_Point;} double LotSize=MathRound((Risk*((Balance/SL)/Tick)/100)/minLot)*minLot; if(!trade.PositionOpen(_Symbol,ORDER_TYPE_SELL,LotSize,Bid,SAR[0],Bid-(SL*5)*_Point,CustomComment)){ Print("PositionOpen error ",trade.ResultRetcode()); return; } }
input double Risk=2.0;
David Diez:
Try my way:
Hi David,
Thanks for helping.
Mind if I ask what does minLot mean?
Does it mean the min lot I can select for the particular symbol ie. (0.01) to ensure that even if the calculation results in anything lesser than (0.01), it would still trigger a (0.01) lot size?
Thanks.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi All,
I wanted my EA to auto calculate the lot sizing based on a fixed 2% on my account balance of ($100,000) against the stop loss I get the the ParabolicSar.
I am not sure what I did wrong here but my EA will not run unless i replace the "lot" variable to an actual lot size like "0.10".
Please do advise. Thank you.