Download MetaTrader 5

Indicators: Optimize single Moving average trading

To add comments, please log in or register
Find out the latest MQL5.community news!
MetaQuotes Software Corp.
Moderator
181194
MetaQuotes Software Corp. 2010.09.22 08:58 

Optimize single Moving average trading:

Optimize trading with a single moving average. This indcator tests each moving average and automatically finds the moving average which fits best to the current market

Author: Thomas Quester

Dua Yong Rew
5424
Dua Yong Rew 2010.09.22 20:05  
1. Time Filter 2. Daily average range
whroeder1
14514
whroeder1 2010.09.24 15:40  
  1. if (Bars != cBars)
           newBar = true;
       else  
           newBar = false;
       cBars = Bars;
    This is unsafe. Once Bars reaches Maximum Bars On Chart, the indicator stops working as Bars and cBars will not change.
    bool newBar = Time0 < Time[0]; Time0 = Time[0];

  2. The code checking for a symbol/TF change is unnecessary. When that occurs you'll get a deInit() init() cycle.
  3. Hard coded array size but never checked if exceeded
    gTradeID++;
       ArrayResize(gTradeOpen,gTradeID+1);
       ArrayResize(gTradeMin,gTradeID+1);
       ArrayResize(gTradeMax,gTradeID+1);
       ArrayResize(gTradeCmd,gTradeID+1);
       ArrayResize(gTradeStart,gTradeID+1);
       ArrayResize(gTradeEnd,gTradeID+1);
    gTradeOpen[gTradeID] = price;
    ...

FXIA
76
FXIA 2010.12.15 02:07  

This indicator has errors when attempting to compile it.

If you manage to fix it please post it in full code post.

To add comments, please log in or register