- if(OrderType() == OP_BUY)
- {
- dSl=OrderStopLoss();
- if( dSl == 0 )
- if( dInitialSL != 0)
- dSl = dnAsk - dInitialSL;
- ArrayResize(arrSL,5);
- ArrayInitialize(arrSL,dSl);
- LogSL("OP_BUY-check",dSl,arrSL[0],arrSL[1],arrSL[2],arrSL[3]);
- if( dPropSLRatio > 0 )
- {
- if( Bid >= (OrderOpenPrice() + dPropSLThreshold) )
- {
- dSl = NormalizeDouble( OrderOpenPrice() + dPropSLRatio*(Bid - OrderOpenPrice()) - dSpread,4 );
- if(OrderStopLoss() < dSl)
- arrSL[1]=dSl;
- }
- else
- {
- if(dTrailingStop != 0)
- arrSL[2]=dnBid - dTrailingStop;
- }
- }
- dSl=arrSL[ArrayMaximum(arrSL)];
- LogSL("OP_BUY - max",dSl,arrSL[0],arrSL[1],arrSL[2],arrSL[3]);
- if( dSl > OrderStopLoss() || OrderStopLoss() == 0 )
- {
- OrderModify(OrderTicket(), OrderOpenPrice(),
- dSl, OrderTakeProfit(), 0, Yellow);
- Log("Buy - modify", OrderOpenPrice(), dSl, OrderTakeProfit());
- }
- // Escape buy
- //if( dEscape != 0 && dnBid < OrderOpenPrice() - dEscape - 5 * Point )
- if( nUseEscape == 1 && dnBid < OrderOpenPrice() - dEscapeLevel - 5 * Point )
- {
- OrderModify(OrderTicket(), OrderOpenPrice(),
- OrderStopLoss(), OrderOpenPrice() + dEscapeTP, 0, Aqua);
- Log("Buy - EscapeLevel", OrderOpenPrice(), dSl, OrderTakeProfit());
- }
|