need help adding and modifying position

 

according to my strategy

ineed help to add and modify position

i had done this but it has problem

if (Volume[0]>1)

return;

//here i want to modify all open orders with new sl

for (ii = OrdersTotal() - 1; ii >= 0;ii--) {

OrderSelect(ii, SELECT_BY_POS, MODE_TRADES);

if (OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==magic) // modification the SL of this buy positin until all buy positions are modified

if (OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==magic )// modification the SL of this sell positin until all sell positions are modified

}

//here i just want to chek last opened position if it was in profit another positin will be opened

i=OrdersTotal();
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if (OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderProfit()>0 && count<maxorder ) buyagain(); //this is void for adding position
if (OrderType()==OP_SELL && OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderProfit()>0 && count<maxorder) sellagain(); //this is void for adding position

if (a==b ) buyposition() ;

if (a==c ) sellposition() ;

return(0);
}

plz help me i am new and confused

 
 

Please insert a complete code. One which preferably compiles.

So far: if (Volume[0]>1)= bad idea. Terminal sometimes misses Volume==1, You'll end up missing some New-Bar processes.

OrderSelect(ii, SELECT_BY_POS, MODE_TRADES), put this within an if()-statement, and check for true or false.

Make sure to use GetLastError and Check the Documentations before running around in cycles.

 
ubzen:

Please insert a complete code. One which preferably compiles.

So far: if (Volume[0]>1)= bad idea. Terminal sometimes misses Volume==1, You'll end up missing some New-Bar processes.

OrderSelect(ii, SELECT_BY_POS, MODE_TRADES), put this within an if()-statement, and check for true or false.

Make sure to use GetLastError and Check the Documentations before running around in cycles.


thank you for quick reply i'll try it