Download MetaTrader 5

Indicators: Optimize single Moving average trading

To add comments, please log in or register
MetaQuotes Software Corp.
Moderator
192540
MetaQuotes Software Corp.  

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
5554
Dua Yong Rew  
1. Time Filter 2. Daily average range
whroeder1
17094
whroeder1  
  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  

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