avatar
BE v1

MarketBuler 24 4th Sep, 2020

CPP 2.26 KB
                                           
                         extern int BE_Point = 10;
extern int BE_Active_Point = 25;
bool OM;

void OnTick()
  {
  
   BE_SL();  
   
  }
//+------------------------------------------------------------------+

void BE_SL ()
{
   for(int be=OrdersTotal()-1;be>=0;be--)
     {
      if(!OrderSelect(be,SELECT_BY_POS,MODE_TRADES))
         continue;
      if(OrderType()==OP_SELL)
         {
            if(OrderStopLoss()>OrderOpenPrice())
            if(Bid<OrderOpenPrice()-BE_Point*_Point)
               {
                  Print(
                        OrderSymbol(),
                        OrderTicket(),
                        OrderOpenPrice(),
                        OrderStopLoss(),
                        OrderTakeProfit(),
                        OrderOpenPrice()-BE_Active_Point*_Point,
                        OrderOpenPrice()-BE_Point*_Point,
                       );
                  OM=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BE_Active_Point*_Point,OrderTakeProfit(),0,CLR_NONE);
                  
                  // nếu modify ko thành công thì in lỗi ra
                  if(!OM)
                  Print("Error in OrderModify. Error code = ",GetLastError());
               }
         }
      
      if(OrderType()==OP_BUY)
         {
            if(OrderStopLoss()<OrderOpenPrice())
            if(Ask>OrderOpenPrice()+BE_Point*_Point)
               {
                  Print(
                        OrderSymbol(),
                        OrderTicket(),
                        OrderOpenPrice(),
                        OrderStopLoss(),
                        OrderTakeProfit(),
                        OrderOpenPrice()+BE_Active_Point*_Point,
                        OrderOpenPrice()+BE_Point*_Point,
                       );
                  OM=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BE_Active_Point*_Point,OrderTakeProfit(),0,CLR_NONE);
                  
                  // nếu modify ko thành công thì in lỗi ra
                  if(!OM)
                  Print("Error in OrderModify. Error code = ",GetLastError());
               }
         }         
     }
}
                      
                                       
To share this paste please copy this url and send to your friends
RAW Paste Data

Comments

Authentication required

You must log in to post a comment.

Log in
    There are no comments yet.