Query about opening positions with same points difference

 

Hello everyone,


I have successfully coded a script that opens positions with a difference of 150 points. My EA opens a buy position every time "Ask>=Price of last buy opened +150_Points"

while(Ask>=B1+(X*PositionB)*_Point && Buy1==1)
    {
        PositionB=PositionB+1;
        OrderSend (_Symbol,OP_BUY,lot,Ask,0,0,0,"B"+PositionB,0,0,Green);
        InfoB=DoubleToStr(B1+(X*PositionB)*_Point,5);
    }


The code is opening the positions however, my problem is that I don't get exactly a 150 Points difference between the positions.. this EA opens 20 Buys and the difference is sometimes 15 sometimes 12 sometimes 19.. I tried limiting this by adding in my while expression:

Ask>=B1+(X*PositionB)*_Point && Ask<=B1+(9+X*PositionB)*_Point && Buy1==1


It didn't work as well.. Did I miss something because I have been going through the material but no outcome.. I thought of opening buystops as well but I would like to know if it is possible to do it this way..


Kind regards,

Abdel

Reason: