// Split lotsNew into three equal trades. double lotStep = MarketInfo(Symbol(), MODE_LOTSTEP), //IBFX= 0.01 minLot = MarketInfo(Symbol(), MODE_MINLOT ); //IBFX= 0.01 for(int split=3; split>0; split--) { // 100.01=33.34+33.34+33.33 double size=MathCeil(lotsNew/split/lotStep)*lotStep; if (size < minLot) continue; lotsNew -= size; OrderSend(... }

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
I am giving the option of a "splitPosition" on X number of requested lots.
Ie, the user might have requested 1 standard lot, or a risk calculation that equates to 1 standard lot, and to split that position into 3 multiple trades.
So i just need the code to split that 1 lot into 3 even sizes, and obviously take care of the correct rounding of numbers and possibility that it will not be even numbers.
So i would assume in this case it would come back with 3 different positions of something like:
Position 1: 0.35
Position 2: 0.35
Position 3: 0.3
Oh and if it takes into account the brokers minimum position etc that would be nice.
Much appreciate your time.