Automated Trading Championship 2007: common mistakes in experts - page 8

 
Either that
 if(OrderStopLoss()!=(Bid-Point*TrailingStop))
Either way we check if the stop loss is in pips and the expression is in pips.

Also, who needs lots in increments of 0.1 and with a limit of up to 5 lots

TmpRound = MathRound(Lots/0.1);
        Lots = TmpRound*0.1;       
        if(Lots>5)Lots=5;
        if(Lots<0.1)Lots=0.1;
 
1) It would be good not only to identify common mistakes in experts, but also to show ways to solve these problems.

2) It would be useful for everybody. But, for example, the classic MACD Sample.mq4 Expert Advisor written as an example by its developers will not pass the test itself because of error #1.
Why would a beginner trader see an example of a correct solution?

3) By the way, it is a great idea to leave a simple Expert Advisor, for example, based on the median, as an example that meets all requirements and sets the good rules for programming an Expert Advisor. A lot of people would appreciate it. That would be a good promotion of MQL4 as a base for building automatic trading systems.
 
AstaLavista:
1) It would be a good idea not only to identify common mistakes in EAs, but also to show ways to solve these problems.

2) All would benefit from it. But, for example, the classical MACD Sample.mq4 Expert Advisor written as an example will not pass the test because of error #1.
Why would a beginner trader see an example of a correct solution?

3) By the way, it is a great idea to leave a simple Expert Advisor, for example, based on the median, as an example that meets all requirements and sets the good rules for programming an Expert Advisor. A lot of people would appreciate it. That would be a good promotion of MQL4 as a base for building automatic trading systems.


Golden words!

I hope this will be taken into account at least in the planned "wizard" code creation templates.

 
2 AstaLavista: Rosh's code for trailing is more correct (although you should change oldTP to oldSL and newTP to newSL in the bracketed comparison line ) - his condition is ">". And in your case, if the price rolls back, then the trailing will roll back as well, because the condition will be met!
 
Stepler2442:
2 AstaLavista: Rosh's code for trailing is more correct (although you should change oldTP to oldSL and newTP to newSL in the bracketed comparison line) - his condition is ">". And in your case, if price rolls back, trailing will also roll back, because the condition will be fulfilled!
In that case, just replace for the case of bay with
 if(OrderStopLoss()<(Bid-Point*TrailingStop)

at equal values the condition will not be fulfilled, avoiding error #1, and at values below the set stop the modification will not be performed - in other words, it will work as a full-fledged Trailing Stop
OrderStopLoss() и (Bid-Point*TrailingStop)

 
Stepler2442:
2 AstaLavista: Rosh's code for trailing is more correct (although you should change oldTP to oldSL and newTP to newSL in the bracketed comparison line) - his condition is ">". And in your case, if the price rolls back, then the trailing will also roll back, because the condition will be met!
Thank you, I corrected it.
 
AstaLavista:
Stepler2442:
2 AstaLavista: Rosh's code for trailing is more correct (although you should change oldTP to oldSL and newTP to newSL in brackets) - he has ">" condition. And in your case, if the price rolls back, then the trailing will also roll back, because the condition will be fulfilled!

In this case, simply replace for the case bay with
 if(OrderStopLoss()<(Bid-Point*TrailingStop)


Yes, it will work. The only difference and some advantage of trailing, suggested by Rosh, is that with it you can easily do not only trailing, but also with steps, so that not to worry about every pip and not to bother your broker with a stream of modifications :)
 

Unfortunately sometimes it won't work (I've been there before), but this will always work:

if(NormalizeDouble(OrderStopLoss(),Digits) < NormalizeDouble(Bid-Point*TrailingStop,Digits))
 
It would be great if we could find the best solution for everything, in the form of an exemplary advisor...
 

Gentlemen, is the log generated as a result of automatic testing available for downloading and viewing? I can't find it in my profile.