void quantum(string symb="")
{
double order_B_price=-1;
double order_S_price=-1;
int type=-1;
string symb_B;
string symb_S;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) continue;
if(OrderMagicNumber()!=Magic || (symb!="" && OrderSymbol()!=symb)) continue;
type=OrderType();
if(order_B_price==-1 && type==OP_BUYSTOP) {order_B_price=OrderOpenPrice();symb_B=OrderSymbol();}
if(order_S_price==-1 && type==OP_SELLSTOP) {order_S_price=OrderOpenPrice();symb_S=OrderSymbol();}
if(order_B_price!=-1 && order_S_price!=-1) break;
}
if(order_B_price!=-1)
{
double point=MarketInfo(symb_B,MODE_POINT)*point_multip;
//
if(MarketInfo(symb_B,MODE_ASK)<=order_B_price+otstup*point)
{
CountOpenedPositions_f(symb);
int ticket_op_m=-1;
for (int j_op_b = 0; j_op_b < MaxAttempts; j_op_b++)
{
while(IsTradeContextBusy()) Sleep(int(pause_if_busy*1000));
RefreshRates();
ticket_op_m=OrderSend(symb,OP_BUYSTOP,NormalizeDouble(Lot,nor_lot),MarketInfo(symb_B,MODE_ASK),Slippage,0,0,comment,Magic,0,clrNONE);
if(ticket_op_m>-1)break;
}
}
}
if(order_S_price!=-1)
{
double point=MarketInfo(symb_S,MODE_POINT)*point_multip;
//
if(MarketInfo(symb_S,MODE_BID)>=order_S_price-otstup*point)
{
CountOpenedPositions_f(symb);
int ticket_op_m=-1;
for (int j_op_s = 0; j_op_s < MaxAttempts; j_op_s++)
{
while(IsTradeContextBusy()) Sleep(int(pause_if_busy*1000));
RefreshRates();
ticket_op_m=OrderSend(symb,OP_SELLSTOP,NormalizeDouble(Lot,nor_lot),MarketInfo(symb_S,MODE_BID),Slippage,0,0,comment,Magic,0,clrNONE);
if(ticket_op_m>-1)break;
}
}
}
}