Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- for(int i=OrdersTotal()-1;i>=0;i--){
- if( OrderSelect(i, SELECT_BY_POS, MODE_TRADES) ){
- // Pula ordens que não sejam desse gráfico
- if( OrderSymbol() != Symbol() && OrderMagicNumber != MagicNumber){ continue; }
- trailling = false;
- if(OrderType()==OP_BUY ){
- if(Bid - OrderStopLoss() >= TraillingStop*pointer){
- SL=NormalizeDouble(Bid-StopLoss*pointer, Digits);
- if( SL > OrderStopLoss() ){ trailling = true; }
- }
- }
- if(OrderType()==OP_SELL ){
- if(OrderStopLoss() - Ask >= TraillingStop*pointer){
- SL=NormalizeDouble(Ask+StopLoss*pointer, Digits);
- if( SL < OrderStopLoss() ){ trailling = true; }
- }
- }
- if(trailling){
- if( !OrderModify(OrderTicket(), OrderOpenPrice(), SL, OrderTakeProfit(), 0) ){
- int Error = GetLastError();
- string ErrorText = ErrorDescription(Error);
- StringToUpper( ErrorText );
- Print("Ordem #", OrderTicket(), " não foi modificada. Código Erro: ", Error, " \"", ErrorText, "\"" );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment