Download MetaTrader 5
To add comments, please log in or register
Does your signal already have a lot of of subscribers? It's time to think about the paid subscription!
ProsteJaa
10
ProsteJaa 2015.02.07 12:05 

Hi there, 

 I have a question regarding moving SL to BE in my EA. Could you please help me?

I want to move to BE when price moves X pips in my favour. Here is part of my code:

 

   void TrailOrder(int type)

{

   

                  

      {

         if(type==OP_BUY)

                  

         {

            if(Bid-OrderOpenPrice()>TrailingStop*Point)

            

               {

                  OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green);

                  Print("Bid-open=",Bid-OrderOpenPrice());

                  Print("TrailingStop*Point=", TrailingStop*Point);

               }

            

         }

         if(type==OP_SELL)

         {

            if((OrderOpenPrice()-Ask)>(TrailingStop*Point))

            

               {

                  OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);

               }

            

         }

      }

   

}

 

 

 

Sorry for dumb question. Im very new in programming. Thank you in advance for your help. I guess condition is never met. I think there is some logical mistake. I tried to print out when conditions are met but never happened. 

SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2015.02.07 12:21  

Please use SRC (besides video icon) when posting codes. Just edit your post.


You need to use loop to identify opened trades. By the way, what you want is actually available at many places. Try googling it.

ProsteJaa
10
ProsteJaa 2015.02.07 12:28  
void TrailOrder(int type)

{

   

                  

      {

         if(type==OP_BUY)

                  

         {

            if(Bid-OrderOpenPrice()>TrailingStop*Point)

            

               {

                  OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Green);

                  Print("Bid-open=",Bid-OrderOpenPrice());

                  Print("TrailingStop*Point=", TrailingStop*Point);
deysmacro:

Please use SRC (besides video icon) when posting codes. Just edit your post.

You need to use loop to identify opened trades. By the way, what you want is actually available at many places. Try googling it.

               }                       }          if(type==OP_SELL)          {             if((OrderOpenPrice()-Ask)>(TrailingStop*Point))                             {                   OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Red);                }                       }       }    }
ProsteJaa
10
ProsteJaa 2015.02.07 12:29  
deysmacro:

Please use SRC (besides video icon) when posting codes. Just edit your post.


You need to use loop to identify opened trades. By the way, what you want is actually available at many places. Try googling it.

aah, so I haven't chosen trade which to modify?
SYED NAUFAL GADDAFI
1401
SYED NAUFAL GADDAFI 2015.02.07 12:52  
Search at google trailing stop mql4. There are many working examples that you can use.
/
To add comments, please log in or register