Let’s examine examples of how indicators behave, focusing on those that draw and those that don’t. For instance, consider how a bar (Candle) indicator might function differently compared to others.
Signal differences in programming. Using the shift parameter
To better understand how indicators work, it’s helpful to explore examples of both drawing indicators and non-drawing indicators.
Drawing indicators (Repaint) are those that plot directly on the price chart, while non-drawing indicators display their output in a separate window.??????NO
Drawing or Redrawing Indicators are technical tools used in trading that modify their signals (such as arrows) or alter the signal direction to provide more accurate indications on the current or previous bars (Candles).
Bar = Candle:
These indicators possess the capability to redraw their signals, which can be considered both a violation of trading integrity and a deceptive practice.
Some indicators intentionally redraw their signals to enhance visual appeal, making the chart more aesthetically pleasing.
Other indicators perform redrawing as part of their mathematical calculations to improve the accuracy and reliability of the signals they generate.
However, it is normal behavior for all indicators to draw on the 0th bar(Candle) or the current bar (Candle) . This initial drawing ensures that the indicator is properly aligned with the latest market data.
Let’s explore the underlying reasons why indicators redraw their signals and the implications this has for trading strategies.
The difference in signals between these two types of indicators can be significant, so understanding their behavior is crucial when programming trading strategies.
One way to influence how indicators behave is by using the shift parameter, which allows you to shift the indicator output forward or backward in time.
By experimenting with different values of the shift parameter, you can fine-tune your indicators to align better with your trading strategy, thereby increasing your chances of success in the market.
And you can check such indicators with the help of the strategy tester using our universal Expert Advisor:
This article was written at the request of our partners.
When ordering Expert Advisor programming, you can adjust the signal bar in all of my advisors.
It’s common to find complaints online that some Expert Advisors do not work correctly due to their indicators.
I will explain these signals in detail and demonstrate the opposite: all indicators draw, and they must simply be used correctly.
There is a video version of this article, but before watching, I recommend reading the text version for a deeper understanding.
Shift (0,1,2…..) Bar (Candle) Number
This parameter represents the number of the Bar from which your indicators will take a signal.
When ordering an Expert Advisor, you must specify the following signal definition parameters: open a deal immediately after the signal, or wait until the signal is formed on a closed Bar and open a deal only at the opening of the next Bar.
Due to their algorithms, some indicators have a clear definition: on which Bar is the signal given?
If we talk about the clarity and correct execution of the order, then the deal must be processed only on a closed Bar, i.e., parameter shift=1.
If it is necessary to open a DEAL immediately upon the occurrence of a signal on the current Bar and the indicator allows this, it is required to set shift=0.
Expert Advisor
The EA is written using our template for writing an EA. All functions of the advisor are described on this page: Forex Advisor Functions.
You can download the package from the link Signal BarTesting Package
1. Moving Average Indicator
The standard indicator of the MT4 terminal includes the averaging period, averaging prices, and the type of averaging in the settings.
Trading Strategy: Crossover of averages. The intersection of slow MA and fast MA.
Strategy Code:
double ExampleMA=iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,shift); // MA Call Example
double ExampleMA2=iMA(Symbol(),0,50,0,MODE_SMA,PRICE_CLOSE,shift); // MA Call Example
double ExampleMA23=iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,shift+1); // MA Call Example
double ExampleMA22=iMA(Symbol(),0,50,0,MODE_SMA,PRICE_CLOSE,shift+1); // MA Call Example
if(ExampleMA23<ExampleMA22 && ExampleMA>ExampleMA2) Sig=1;
if(ExampleMA23>ExampleMA22 && ExampleMA<ExampleMA2) Sig=2;
Examples of Work with Shift = 0
Examples of Work with Shift = 1
Explanation: This indicator does not draw, allowing it to be used with any shift.
Video Example:
2. Indicator Cross
A custom indicator based on the MA crossing strategy with additional features. It draws prominently with precision. Crossing on 1 Bar draws an arrow at the 0 Bar and continuously redraws it.
Explanation: This indicator draws prominently, and the developer deliberately redraws the signal. Therefore, it is risky to use this indicator as a signal indicator.
Video Example:
3. CurrencyPowerMeter Indicator
A custom indicator that measures the strength of currencies. This indicator operates using objects, so shift is irrelevant. The trading strategy for this indicator is based on pulling the value not from the indicator buffer but from the indication of the object on the chart.
Trading Strategy: Trading the difference between currency strengths
Explanation: This indicator does not have indicator buffers and is based on objects. Therefore, the signal bar does not matter. Such indicators cannot be tested or optimized and work only in real-time.
Video Example:
4. Fiji Trend Indicator
A custom indicator that works on MA and ATR signals in the form of arrows. It does not draw the indicator, but with a small trick, the indicator takes data from closed Bars but places an arrow on the current 0 Bar. It’s an illusion of deceit.
Trading Strategy: Trading on the arrows of the indicator
Strategy Code:
int Sig=0;
double DNSignal=iCustom(Symbol(),0,"Fiji Trend",3,shift); // An example of calling a custom indicator
double UPSignal=iCustom(Symbol(),0,"Fiji Trend",2,shift); // An example of calling a custom indicator
double DNTrend=iCustom(Symbol(),0,"Fiji Trend",1,shift); // An example of calling a custom indicator
double UPTrend=iCustom(Symbol(),0,"Fiji Trend",0,shift); // An example of calling a custom indicator
// Specify Signals for Opening:
if( UPSignal!=EMPTY_VALUE) Sig=1;
if( DNSignal!=EMPTY_VALUE) Sig=2;
Examples of Work with Shift = 0
Examples of Work with Shift = 1
Explanation: This indicator does not draw. However, it places signals using the aforementioned trick. It is one of the few indicators that provide reasonably good signals.
Video Example:
5. Fisher Indicator
A custom indicator that operates on Hi-Lo Bars and calculates signals based on its formulas. It draws as demonstrated by the tests and redraws 3-5 Bars on closed Bars, presented in the form of a histogram.
Explanation: This indicator does not draw. However, it places signals using the aforementioned trick. It is one of the few indicators that provide reasonably good signals.
Video Example:
7. MACD Indicator
Standard MT terminal indicator.
Trading Strategy: Trading on the intersection of the signal line and the histogram
Strategy Code:
int Sig=0;
double MACD_SIGNAL1=iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,shift); // MA Call Example
double MACD_SIGNAL2=iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_SIGNAL,shift+1); // MA Call Example
double MACD_MAIN1=iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_MAIN,shift); // MA Call Example
double MACD_MAIN2=iMACD(Symbol(),0,12,26,9,PRICE_CLOSE,MODE_MAIN,shift+1); // MA Call Example
if(MACD_SIGNAL2<MACD_MAIN2 && MACD_SIGNAL1>MACD_MAIN1) Sig=1;
if(MACD_SIGNAL2>MACD_MAIN2 && MACD_SIGNAL1<MACD_MAIN1) Sig=2;
Examples of Work with Shift = 0
Examples of Work with Shift = 1
Explanation: This indicator does not redraw on 1 closed Bar, so you can freely use shift=1.
Video Example:
8. ZIGZAG Indicator
Standard MT terminal indicator. Builds tops and bottoms based on the high-low of a specific area.
Trading Strategy: Trade on the formation of tops and bottoms. It is not recommended to trade on the indicator with positions. It’s a good limit strategy.
Explanation: This indicator draws tops and bottoms, so shift is irrelevant. The unique conditions of the strategy allow successful trading on this indicator.
Video Example:
9. BARS Work on Request
Operates on the standard Bars of the MT terminal.
Trading Strategy: If the Bar is bullish, open a buy; if the Bar is bearish, open a sell.
Strategy Code:
int Sig=0;
if(Open[shift] < Close[shift]) Sig=1;
if(Open[shift] > Close[shift]) Sig=2;
Examples of Work with Shift = 0
Examples of Work with Shift = 1
Explanation: A perfect example of how the shift parameter works, demonstrating how you can trade strategies based on this parameter.
Video Example:
Conclusions
This informative article provides helpful examples of using various indicators with different values of the shift parameter.
Each indicator is unique; thus, when creating an Expert Advisor, the type of indicator and its signal must be taken into account.
Before hiring a programmer to create an Expert Advisor, it is important to first test your indicator for any potential issues with redrawing.
This is crucial since the reliability and effectiveness of your robot’s trades will depend on the accuracy of your indicator.
Therefore, it is recommended that you thoroughly check and test your indicator before proceeding with the creation of your Expert Advisor.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Leave a Reply