How to remove built-in Indicator lines on Strategy tester in Visual Mode?

 

Hello

I want to hide some built-in indicator lines in my EA when I use Visual Mode on Strategy tester. For example I want to hide iATR() lines but show iMA() lines. I usually use 3 ATRs in my EAs, and hence each opens in a new sub-window, it is too disturbing.

I don't want to use 

TesterHideIndicators(true);

since it hides all indicator lines of the chart.

The Fundamentals of Testing in MetaTrader 5
The Fundamentals of Testing in MetaTrader 5
  • www.mql5.com
What are the differences between the three modes of testing in MetaTrader 5, and what should be particularly looked for? How does the testing of an EA, trading simultaneously on multiple instruments, take place? When and how are the indicator values calculated during testing, and how are the events handled? How to synchronize the bars from different instruments during testing in an "open prices only" mode? This article aims to provide answers to these and many other questions.
 
Alex trader:

I want to hide some built-in indicator lines in my EA when I use Visual Mode on Strategy tester.

  1. Add the desired indicators to your chart.
  2. Modify the indicator's line color to None to be hidden while running visual mode on Strategy.
  3. Once you're satisfied with your setup, navigate to Charts > Templates > Save Template in the toolbar to save your chart configuration.
  4. In the Strategy Tester's toolbar, go to Charts > Templates > Load Template, then load the saved template.

Alternatively, you can modify the indicator's code directly by adding an input option to toggle plot visibility, or set the line color to clrNone to hide it.

 
MAHA #:
  1. Add the desired indicators to your chart.
  2. Modify the indicator's line color to None to be hidden while running visual mode on Strategy.
  3. Once you're satisfied with your setup, navigate to Charts > Templates > Save Template in the toolbar to save your chart configuration.
  4. In the Strategy Tester's toolbar, go to Charts > Templates > Load Template, then load the saved template.

Alternatively, you can modify the indicator's code directly by adding an input option to toggle plot visibility, or set the line color to clrNone to hide it.

Thank you very much.

 
Alex trader:

Hello

I want to hide some built-in indicator lines in my EA when I use Visual Mode on Strategy tester. For example I want to hide iATR() lines but show iMA() lines. I usually use 3 ATRs in my EAs, and hence each opens in a new sub-window, it is too disturbing.

I don't want to use 

since it hides all indicator lines of the chart.

Actually You can call the handle of the indicator you want to show before TesterHideIndicators(true);. Like it only hides any handle after it. 
 

Have you tried plotting ATR value in main chart instead?

 
Sander Maehle Andresen #:
Actually You can call the handle of the indicator you want to show before TesterHideIndicators(true);. Like it only hides any handle after it. 

Very very useful method. Thank you very much!

This method helped me a lot.

 
Matthew88819 #:

Have you tried plotting ATR value in main chart instead?

When I call iAtr function, it always opens in a new sub-window. Hence I don't know how to plot such an indicator in the main window.

 

You could hide any plot this way:

- Use a DRAW_COLOR_LINE or DRAW_COLOR_SECTION drawing style, and set clrNONE as the last color index (index 2 in this case)

#property indicator_label1  "MA Line"
#property indicator_type1   DRAW_COLOR_LINE
#property indicator_color1  clrGreen, clrRed, clrNONE
#property indicator_width1  2

clrGreen = index 0

clrRed = index 1

clrNONE = index 2


Then in OnCalculate, you can color the line to none exclusively for the strategy tester

if(MQLInfoInteger(MQL_TESTER) || MQLInfoInteger(MQL_VISUAL_MODE)) 
            for(int i=0; i<rates_total && !IsStopped(); i++) color_buf[i] = 2; // the index 2 is where clrNONE is configured
 
Alex trader #:

When I call iAtr function, it always opens in a new sub-window. Hence I don't know how to plot such an indicator in the main window.

ATR can't be plotted on the main chart because it's not outputting OHLC prices, it outputs a measure of the market volatility. If you want a chart based ATR indicator, then you need to use ATR only for calculations upon the OHLC prices, and then represent the calculated values in new plot buffer.

So what it sounds like you need to do is build an indicator with the number of ATRs that you want, assign them for calculation only in the indicator (they will not be plotted), and plot whatever you want to be plotted from the custom indicator.
 
Alex trader #: When I call iAtr function, it always opens in a new sub-window. Hence I don't know how to plot such an indicator in the main window.

Your choices are as follows:

  • You can code the ATR calculations directly in the EA (quite simple), so that no indicator is used, or ...
  • ... you can code your own custom indicator to calculate the ATR (or adapt from a CodeBase publication), and have it able to disable the plot, or ...
  • if you insist on using iATR(), then you have no choice but to use TesterHideIndicators(true).
 
Conor Mcnamara #:

You could hide any plot this way:

- Use a DRAW_COLOR_LINE or DRAW_COLOR_SECTION drawing style, and set clrNONE as the last color index (index 2 in this case)

clrGreen = index 0

clrRed = index 1

clrNONE = index 2


Then in OnCalculate, you can color the line to none exclusively for the strategy tester

Conor Mcnamara #:

ATR can't be plotted on the main chart because it's not outputting OHLC prices, it outputs a measure of the market volatility. If you want a chart based ATR indicator, then you need to use ATR only for calculations upon the OHLC prices, and then represent the calculated values in new plot buffer.

So what it sounds like you need to do is build an indicator with the number of ATRs that you want, assign them for calculation only in the indicator (they will not be plotted), and plot whatever you want to be plotted from the custom indicator.
Fernando Carreiro #:

Your choices are as follows:

  • You can code the ATR calculations directly in the EA (quite simple), so that no indicator is used, or ...
  • ... you can code your own custom indicator to calculate the ATR (or adapt from a CodeBase publication), and have it able to disable the plot, or ...
  • if you insist on using iATR(), then you have no choice but to use TesterHideIndicators(true).

Thank you. Your suggestions improved my understanding regarding MQL5.