Download MetaTrader 5
To add comments, please log in or register
Publish your article to let the traders see it in MetaTrader 5!
rr
19
rr 2014.02.19 13:55 

Hi, I'm trying to do an EMA of an indicator (ADX) in an EA, but I must be doing something wrong cause it doesn't work.

I attach some lines of the code:

<Please use SRC Button>

Fisrt of all, what I have to do to see this ema on the screen in a backtest for example? And second, if I try to backtest this EA, the value of maADX it's not the same as if I drag a moving average (period 50) to the ADX indicator with Previous Indicator's Data option.

Simon Gniadkowski
Moderator
17962
Simon Gniadkowski 2014.02.19 14:22  
tradefish:

Hi, I'm trying to do an EMA of an indicator (ADX) in an EA, but I must be doing something wrong cause it doesn't work.

I attach some lines of the code:

<REMOVED>

Please use the SRC button to post code . . .
whroeder1
13597
whroeder1 2014.02.19 14:43  
tradefish: I'm trying to do an EMA of an indicator (ADX) in an EA, but I must be doing something wrong cause it doesn't work.
  1. Use SRC. Please edit your post.
  2. Set the ADXarray as series so it knows array[0] is the newest like the chart.
rr
19
rr 2014.02.19 17:34  
WHRoeder:
  1. Use SRC. Please edit your post.
  2. Set the ADXarray as series so it knows array[0] is the newest like the chart.
for ( int j=0;j<1000;j++)
    {
      ADXarray[j]=iADX(NULL,0,period,0,0,j);
    }
    ArraySetAsSeries(ADXarray,true);
    
    maADX=iMAOnArray(ADXarray,0,50,0,MODE_EMA,1);

Ok, here is the code. I've used ArraySetAsSeries and now it works (thanks WHRoeder). The only missing thing is that I don't know how to show this ema when I backtest. After stopping the backtest I see the ADX, but not the ema. In fact, it's not very important, I can drag the ema to the ADX to see if everything is ok....
whroeder1
13597
whroeder1 2014.02.19 17:59  
      ADXarray[j]=iADX(NULL,0,period,0,0,j);
    }
    ArraySetAsSeries(ADXarray,true);
BEFORE you use it
/
To add comments, please log in or register