Download MetaTrader 5
To add comments, please log in or register
Make screenshots in MetaTrader and manage them in the gallery!
Tim
5
Tim 2014.11.03 12:02 

Hi all,

I have just started trading an ea on my live mt4 account through ic markets. In the demo account and strategy tester the ea worked as expected with stop loss taking effect as soon as the position moves in my favour, rather than waiting for the position to become profitable. I have read in several places that by design Mt4 does not activate trailing stops until the position moves in your favour by the number of pips of your trailing stop. I wanted to have a trailing stop that activated as soon as my position moved in my direction so as to minimise loss on losing trades as well as allow winning trades to run their course.

 

I thought i had achieved what i wanted simply by commenting out the relavant  line of code as shown below:

 if(TrailingStop>0)  

              {                 

              // if(Bid-OrderOpenPrice()>MyPoint*TrailingStop)                       //This line commented out in ea

                 {

                  if(OrderStopLoss()<Bid-MyPoint*TrailingStop)

                    {

                     OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);

                     return(0);

                    }

                 } 

 

Can anyone explain why this works in demo but not live account?

It worked well in about a month of forward testing via my demo account and also worked as expected in the strategy tester.

Now that i have activated the ea in my live account the modify of the stop loss does not appear to be working as it did in the demo account. Is there indeed any way to have trailing stops activate as soon as a position moves in you favour or is this a limitation of MT4?

I am also confused as to why the strategy tester gives me different results for different optimization runs of trailing stop. On the US500 i am using a SL of 550 and a trailing stop of 640. To my mind this should make the trailing stop irrelevant, as the SL will always trigger first as it is constantly modified by the ea in the same way a trailing stop should work?? Have i got the functioning of SL and TS in Mt4 wrong?

 

Thanks in advance for your responses,

Tim. 

whroeder1
13596
whroeder1 2014.11.03 15:06  
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*MyPoint,OrderTakeProfit(),0,Green);
    Where did you select an order? Did you filter by pair and MN? order accounting - MQL4 forum Do you only open buys?
  3. Check your return codes (any find out why) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
/
To add comments, please log in or register