I'm going crazy! I have no idea whats is wrong!
I need to close the open position (buy or sell) after new bar is close below the early bar if the position is buy or close when next bar closing under the earler bar close then the sell is close.
please help me with this code!
Thanks
http://iv.pl/images/66713794647321163687.jpg
I need to close the open position (buy or sell) after new bar is close below the early bar if the position is buy or close when next bar closing under the earler bar close then the sell is close.
please help me with this code!
Thanks
http://iv.pl/images/66713794647321163687.jpg
Inserted Code
if(iClose(NULL,PERIOD_M30,0)<iClose(NULL,PERIOD_M30,1)) CloseBuy=1;
if(iClose(NULL,PERIOD_M30,0)>iClose(NULL,PERIOD_M30,1)) CloseSell=1;
if(OrdersTotal()>0){
for(i=1; i<=OrdersTotal(); i++) // Cycle searching in orders
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
{
if(OrderMagicNumber()==MagicNumber1) {int halt1=1;}
if(OrderMagicNumber()==MagicNumber2) {int halt2=1;}
}
}
}
.....
// Open buy direct
if(BarOneUp==1&&BarTwoUp==1&&BarThreeUp==1&&halt1!=1){
int openbuy=OrderSend(Symbol(),OP_BUY,Lots,Ask,Slippage,slb,tpb,"Candle bug buy order",MagicNumber1,0,Blue);
if(ReverseClose==true)closesell=1;
}
// Open sell direct
if(BarOneDown==1&&BarTwoDown==1&&BarThreeDown==1&&halt2!=1){
int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,sls,tps,"Candle bug sell order",MagicNumber2,0,Green);
if(ReverseClose==true)closebuy=1;
.......
if(closesell==1||closebuy==1){// start
if(OrdersTotal()>0){
for(i=1; i<=OrdersTotal(); i++){ // Cycle searching in orders
if (OrderSelect(i-1,SELECT_BY_POS)==true){ // If the next is available
if(OrderMagicNumber()==MagicNumber1&&closebuy==1&& CloseBuy==1) { OrderClose(OrderTicket(),OrderLots(),Bid,Slippage,CLR_NONE) ;}
if(OrderMagicNumber()==MagicNumber2&&closesell==1&& CloseSell==1) { OrderClose(OrderTicket(),OrderLots(),Ask,Slippage,CLR_NONE); }
}
}
}
}
}