void ModeOOP()
{
bool m;
double delta=0,oop=0,sl=0,tp=0;
for(int i=OrdersTotal()-1; i>=0; i--)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_BUYSTOP)
{
delta=NormalizeDouble(OrderOpenPrice()-Bid,_Digits);
if(delta>Step*_Point)
{
oop=NormalizeDouble(Bid+Delta*_Point,_Digits);
//sl=NormalizeDouble(oop-StopLoss*_Point,_Digits);
//tp=NormalizeDouble(oop+TakeProfit*_Point,_Digits);
m=OrderModify(OrderTicket(),oop,sl,tp,0,Green);
return;
}
}
if(OrderType()==OP_SELLSTOP)
{
delta=NormalizeDouble(Bid-OrderOpenPrice(),_Digits);
if(delta>Step*_Point)
{
oop=NormalizeDouble(Bid-Delta*_Point,_Digits);
//sl=NormalizeDouble(oop+StopLoss*_Point,_Digits);
//tp=NormalizeDouble(oop-TakeProfit*_Point,_Digits);
m=OrderModify(OrderTicket(),oop,sl,tp,0,Tomato);
return;
}
}
}
}
}
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
if(CountTrades()<1)
{
PutOrder(0,Ask);
PutOrder(1,Bid);
ModifyOrders();
}
if(FindLastBuyPrice()-Ask>=Step*_Point)
{
if(CountOrders(4)<1)
PutOrder(4,Bid+Delta*_Point);
ModifyOrders();
}
if(Bid-FindLastSellPrice()>=Step*_Point)
{
if(CountOrders(5)<1)
PutOrder(5,Bid-Delta*_Point);
ModifyOrders();
}
ModeOOP();
if(TrailingStop>0)
Trailing();
if(AllProfit()>Profit && Profit>0)
CloseAll();
double pro=NormalizeDouble(AllProfit()*100/AccountBalance(),2);
if(pro>Procent && Procent>0)
CloseAll();
Comment("\n Lot: ",Lot(),
"\n Trades: ",CountTrades(),
"\n Profit: ",AllProfit(),
"\n Procent: ",pro);
}
//+------------------------------------------------------------------+
kasparsvas16