Download MetaTrader 5

Please help! Custom indicator, which call an other indicator, is not shown in the strategy tester

To add comments, please log in or register
ugo
50
ugo  

Hi everybody,

I really need you help:

I have an expert advisor that uses ChartIndicatorAdd() to show in a sub window an indicator. Inside this indicator, there is a call to another indicator. (The second one is necessary to compute the first one.)
This second one in not shown in the Strategy tester. Any idea?

Example:

//---  code in the Expert advisor:

int OnInit()
  {
...
   IndHandle     = iCustom(NULL,0,"Examples\\RSI",14);
   int windows  = (int)ChartGetInteger(0,CHART_WINDOWS_TOTAL);

   if(IndHandle==INVALID_HANDLE)         {Print("The Indicator was not created: Error ",GetLastError()); return(0);}
   else                                                  {Print("The IndHandle OK"); ChartIndicatorAdd(0,windows,IndHandle);}

...}

This display properly the RSI in a subwindow of the strat. tester.


Now let say that we have a modified RSI to call for example the stochastic in the same manner:

//--- code in the Modified RSI:
int OnInit()
  {

   IndHandle     = iCustom(NULL,0,"Examples\\Stochastic",5,3,3);
   int windows  = (int)ChartGetInteger(0,CHART_WINDOWS_TOTAL);
   if(IndHandle==INVALID_HANDLE)         {Print("The Indicator was not created: Error ",GetLastError()); return(0);}
   else                                                  {Print("The IndHandle OK"); ChartIndicatorAdd(0,windows,IndHandle);}

...}


In the normal Charting are displayed properly both the RSI (in a subwindow) and the Stochastic (in a different subwindow). BUT in the Strategy Tester only the RSI is shown.

By the way, if you load in the strategy tester directly just the modified RSI, the behaviour is the same: the RSI is shown, the Stochastic not.

Alain Verleyen
Moderator
31206
Alain Verleyen  

Forum on trading, automated trading systems and testing trading strategies


Hello,

Please use the SRC button when you post code. Thank you.


This time, I edited it for you.


ugo
50
ugo  
angevoyageur:

Hups,

Thanks!

ugo

ugo
50
ugo  

The only way around that I have found is to duplicate the call of the second indicator (the Stoch in the example above).

once inside the main indicator (in the example above RSI) and again inside the expert. This last one is used only for display purpose.

Not very elegant but it works.

Anybody has a better idea?

ugo

Alain Verleyen
Moderator
31206
Alain Verleyen  
ugo:

The only way around that I have found is to duplicate the call of the second indicator (the Stoch in the example above).

once inside the main indicator (in the example above RSI) and again inside the expert. This last one is used only for display purpose.

Not very elegant but it works.

Anybody has a better idea?

ugo

You can use a template with the name of your EA.
ugo
50
ugo  

Thanks Angevoyager,

Sorry but I am not sure I understand what you mean.

Alain Verleyen
Moderator
31206
Alain Verleyen  
ugo:

Thanks Angevoyager,

Sorry but I am not sure I understand what you mean.

Documentation :

If the terminal sets a template with the name tester.tpl in the directory/profiles/templates of the client terminal, then it will be applied to the opened chart. In its absence, the default template is applied. (default.tpl).

You can also create a template with the name of your EA.

To add comments, please log in or register