if you mean you want the indicator to be visually present then you have to load it manually on the chart.
The indicators are not visually present in the tester because it slows down the speed of testing.
if you mean you want the indicator to be visually present then you have to load it manually on the chart.
The indicators are not visually present in the tester because it slows down the speed of testing.
Thanks Marco for your answer.
Do you mean that it's possible to load manually an indicator on strategy tester ? How ?
Hi, i'm working on custom indicator but when i added ChartIndicatorAdd that doesn't work on strategy tester, but that's work fine on the main MT5 program.
Is there something wrong in this code ?
What is the error code ?
Indicators are automatically added by the Strategy Tester.
You can't add indicator manually with MT5 but you can use template.
Press pause load indicator then continue testing ?
What is the error code ?
Indicators are automatically added by the Strategy Tester.
You can't add indicator manually with MT5 but you can use template.
I have the same problem. Eager to know the solution.
In my opinion, your code has no problem. It seems that Strategy Tester does not support an indicator loads another indicator. Avoid this way.

- www.mql5.com
I looked into this problem deeply, have got conclusions as below.
1. My scenario is that EA loads indicator A and in turns indicator A loads indicator B. Use ChartIndicatorAdd to show the indicators. It works well but does not work well in the circustance of Strategy Tester. In Strategy Tester, indicator A shows up, but indicator B never shows up.
2. the calls to ChartIndicatorAdd always return success. However, ChartIndicatorName() can't return the newly added name, ChartIndicatorsTotal() returns 0.
3. My work-around way is that EA load indicator A and indicator B in OnInit() process. Indicator A searches the handle of indicator B in the event of OnCalcute() for the first time. it shouldn't be done in the event of OnInit(). This work-around works well.
I looked into this problem deeply, have got conclusions as below.
1. My scenario is that EA loads indicator A and in turns indicator A loads indicator B. Use ChartIndicatorAdd to show the indicators. It works well but does not work well in the circustance of Strategy Tester. In Strategy Tester, indicator A shows up, but indicator B never shows up.
2. the calls to ChartIndicatorAdd always return success. However, ChartIndicatorName() can't return the newly added name, ChartIndicatorsTotal() returns 0.
3. My work-around way is that EA load indicator A and indicator B in OnInit() process. Indicator A searches the handle of indicator B in the event of OnCalcute() for the first time. it shouldn't be done in the event of OnInit(). This work-around works well.
I'm have similar problem. What happens it that sometimes B finds A, sometimes not. ChartIndicatorAdd always returns true, but I can't visualize it on the chart.

- www.mql5.com
I looked into this problem deeply, have got conclusions as below.
1. My scenario is that EA loads indicator A and in turns indicator A loads indicator B. Use ChartIndicatorAdd to show the indicators. It works well but does not work well in the circustance of Strategy Tester. In Strategy Tester, indicator A shows up, but indicator B never shows up.
2. the calls to ChartIndicatorAdd always return success. However, ChartIndicatorName() can't return the newly added name, ChartIndicatorsTotal() returns 0.
3. My work-around way is that EA load indicator A and indicator B in OnInit() process. Indicator A searches the handle of indicator B in the event of OnCalcute() for the first time. it shouldn't be done in the event of OnInit(). This work-around works well.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, i'm working on custom indicator but when i added ChartIndicatorAdd that doesn't work on strategy tester, but that's work fine on the main MT5 program.
Here is a sample code:
//| test-ChartIndicatorAdd.mq5 |
//| Copyright 2016, CPM Corp. |
//| |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, CPM Corp."
#property version "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
//--- plot RSI
#property indicator_label1 "RSI"
#property indicator_type1 DRAW_LINE
#property indicator_color1 clrRed
#property indicator_style1 STYLE_SOLID
#property indicator_width1 1
//--- input parameters
input int InpMaPeriod=10;
input int InpRsiPeriod=13;
//--- indicator buffers
double RsiBuffer[];
double MaBuffer[];
int MaHandle;
int RsiHandle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,RsiBuffer,INDICATOR_DATA);
SetIndexBuffer(1,MaBuffer,INDICATOR_CALCULATIONS);
RsiHandle=iRSI(_Symbol,_Period,InpRsiPeriod,PRICE_CLOSE);
if(RsiHandle==INVALID_HANDLE)
{
Print("The RSI handle is not created: Error ",GetLastError());
return(INIT_FAILED);
}
MaHandle=iMA(_Symbol,_Period,InpMaPeriod,0,MODE_EMA,PRICE_CLOSE);
if(MaHandle==INVALID_HANDLE)
{
Print("The MA handle is not created: Error ",GetLastError());
return(INIT_FAILED);
}
if(!ChartIndicatorAdd(0,0,MaHandle))
{
Print("Failed to add MaHandle indicator to chart window: Error ",GetLastError());
}
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &high[],
const double &low[],
const double &close[],
const long &tick_volume[],
const long &volume[],
const int &spread[])
{
//---
CopyBuffer(RsiHandle,0,0,rates_total,RsiBuffer);
CopyBuffer(MaHandle,0,0,rates_total,MaBuffer);
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
Is there something wrong in this code ?