int b,s,p,res;
datetime expiration = TimeCurrent()+3600*Expiration;
double BuyPrice=Ask+Delta*Point;
double SellPrice=Bid-Delta*Point;
if(Volume[0]>1) return;
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS)==true)
{
if (OrderSymbol()!=Symbol() || OrderMagicNumber()!=MAGIC) continue;
if (OrderType()==OP_BUY || OrderType()==OP_SELL) p++;
if (OrderType()==OP_BUYSTOP) b++;
if (OrderType()==OP_SELLSTOP) s++;
}
}
//---- buy stop
if(Close[1]-Open[1]>0 && Hour()==StartHour && p<1 && b<1)
{
res=OrderSend(Symbol(),OP_BUYSTOP,Lot,BuyPrice,0,BuyPrice-StopLoss*Point,BuyPrice+TakeProfit*Point,"",MAGIC,expiration,Blue);
}
//---- sell stop
if(Open[1]-Close[1]>0 && Hour()==StartHour && p<1 && s<1)
{
res=OrderSend(Symbol(),OP_SELLSTOP,Lot,SellPrice,0,SellPrice+StopLoss*Point,SellPrice-TakeProfit*Point,"",MAGIC,expiration,Red );
}
//----
return(0);