Download MetaTrader 5
To add comments, please log in or register
Share your program via Code Base. Gain access to millions of traders!
ugo
50
ugo 2014.06.13 11:31 

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
30298
Alain Verleyen 2014.06.13 14:51  

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 2014.06.13 16:39  
angevoyageur:

Hups,

Thanks!

ugo

ugo
50
ugo 2014.06.14 09:11  

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
30298
Alain Verleyen 2014.06.14 11:10  
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 2014.06.16 11:18  

Thanks Angevoyager,

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

Alain Verleyen
Moderator
30298
Alain Verleyen 2014.06.16 11:56  
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