Functional features and parameters of experts from expforex.com
Benefits of Ready-Made Experts vs. Programming / Freelance.
Description
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:
EA The xCustomEA: Universal Trading Advisor for iCustom Indicators. Custom Strategy Builder
Or in the strategy tester using our Simulator:
Forex Tester Pad is a Forex trading simulator for strategy tester. Trading using indicators.
Foreword
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 Bar Testing 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.
Trading Strategy: Arrow Trading
Strategy Code:
int Sig=0; if(shift!=-1) { double UP=iCustom(Symbol(),0,"cross",0,shift); double DN=iCustom(Symbol(),0,"cross",1,shift); } if(shift==-1) for(int i=1;i<=100;i++) { UP=iCustom(Symbol(),0,"cross",0,i); DN=iCustom(Symbol(),0,"cross",1,i); if(UP!=EMPTY_VALUE || DN!=EMPTY_VALUE) break; } if(UP!=EMPTY_VALUE){Sig=1;} if(DN!=EMPTY_VALUE){Sig=2;}
Examples of Work with Shift = 0
Examples of Work with Shift = 1
Examples of Work with Shift = -1
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
Strategy Code:
double EUR_HOUR[1]; double GBP_HOUR[1]; double AUD_HOUR[1]; double NZD_HOUR[1]; double USD_HOUR[1]; double CAD_HOUR[1]; double CHF_HOUR[1]; double JPY_HOUR[1]; double PervayaValuta; double VtorayaValuta; string note=" Authentication SETTINGS =="; string username = ""; string password = ""; double trend; string DATATRend; trend=iCustom(Symbol(),0,"CurrencyPowerMeter",0,0); EUR_HOUR[0]=StringToDouble(ObjectDescription("CPMEUR_Str_h")); GBP_HOUR[0]=StringToDouble(ObjectDescription("CPMGBP_Str_h")); AUD_HOUR[0]=StringToDouble(ObjectDescription("CPMAUD_Str_h")); NZD_HOUR[0]=StringToDouble(ObjectDescription("CPMNZD_Str_h")); USD_HOUR[0]=StringToDouble(ObjectDescription("CPMUSD_Str_h")); CAD_HOUR[0]=StringToDouble(ObjectDescription("CPMCAD_Str_h")); CHF_HOUR[0]=StringToDouble(ObjectDescription("CPMCHF_Str_h")); JPY_HOUR[0]=StringToDouble(ObjectDescription("CPMJPY_Str_h")); if(StringSubstr(Symbol(),0,3)=="USD") PervayaValuta=USD_HOUR[0]; if(StringSubstr(Symbol(),0,3)=="GBP") PervayaValuta=GBP_HOUR[0]; if(StringSubstr(Symbol(),0,3)=="EUR") PervayaValuta=EUR_HOUR[0]; if(StringSubstr(Symbol(),0,3)=="AUD") PervayaValuta=AUD_HOUR[0]; if(StringSubstr(Symbol(),0,3)=="NZD") PervayaValuta=NZD_HOUR[0]; if(StringSubstr(Symbol(),0,3)=="CAD") PervayaValuta=CAD_HOUR[0]; if(StringSubstr(Symbol(),0,3)=="CHF") PervayaValuta=CHF_HOUR[0]; if(StringSubstr(Symbol(),0,3)=="JPY") PervayaValuta=JPY_HOUR[0]; if(StringSubstr(Symbol(),3,3)=="USD") VtorayaValuta=USD_HOUR[0]; if(StringSubstr(Symbol(),3,3)=="GBP") VtorayaValuta=GBP_HOUR[0]; if(StringSubstr(Symbol(),3,3)=="EUR") VtorayaValuta=EUR_HOUR[0]; if(StringSubstr(Symbol(),3,3)=="AUD") VtorayaValuta=AUD_HOUR[0]; if(StringSubstr(Symbol(),3,3)=="NZD") VtorayaValuta=NZD_HOUR[0]; if(StringSubstr(Symbol(),3,3)=="CAD") VtorayaValuta=CAD_HOUR[0]; if(StringSubstr(Symbol(),3,3)=="CHF") VtorayaValuta=CHF_HOUR[0]; if(StringSubstr(Symbol(),3,3)=="JPY") VtorayaValuta=JPY_HOUR[0]; if(PervayaValuta - VtorayaValuta > 0) return(1); if(PervayaValuta - VtorayaValuta < 0) return(2); return(0);
Work Examples
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.
Trading Strategy: Histogram Trading. Histogram crossing 0 marks.
Strategy Code:
int Sig=0; double DNSignal=iCustom(Symbol(),0,"Fiji Trend",3,shift); // An example of calling a custom indicator double Fisher1=iCustom(Symbol(),0,"fisher",0,shift); double Fisher2=iCustom(Symbol(),0,"fisher",0,shift); if( Fisher1>0 && Fisher2>0 ){ Sig=1; } if( Fisher1<0 && Fisher2<0 ){ Sig=2; } // 1 - Buy, 2 - Sell return(Sig);
Examples of Work with Shift = 0
Examples of Work with Shift = 1
Explanation: This indicator draws, so I do not recommend taking signals from it.
Video Example:
6. HMA Color Indicator
A custom indicator that operates on MA and calculates signals based on its formulas.
Trading Strategy: Color Change Trading
Strategy Code:
int Sig=0; double HMARED=iCustom(Symbol(),0,"HMA Color",3,shift); double HMAGREEN=iCustom(Symbol(),0,"HMA Color",1,shift); double HMARED2=iCustom(Symbol(),0,"HMA Color",3,shift+1); double HMAGREEN2=iCustom(Symbol(),0,"HMA Color",1,shift+1); // Specify Signals for Opening: if(HMAGREEN!=EMPTY_VALUE && HMAGREEN2==EMPTY_VALUE) Sig=1; if(HMARED!=EMPTY_VALUE && HMARED2==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:
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.
Strategy Code:
int Sig=0; double PriceZZ1=GetExtremumZZPrice(Symbol(),0,1); double PriceZZ2=GetExtremumZZPrice(Symbol(),0,2); double priceUP, priceDN; if(PriceZZ2>PriceZZ1) { priceUP=PriceZZ2; priceDN=PriceZZ1; Sig=2; } if(PriceZZ2<PriceZZ1) { priceUP=PriceZZ1; priceDN=PriceZZ2; Sig=1; }
Examples of Work with Shift = 0
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.
Advisor
The EA is written using our template for writing an EA.
All advisor functions are described on this page: Forex Advisor Functions.
If you want to create an alert for your indicator, please read our article:
Questions?
If you have any questions, please ask them. We do not sell the pig in a poke.
Each of our products can be tested before purchase.
We appreciate your feedback and wishes for our products and strive to maintain high-quality standards.
Thank you for being with us!
Do you have a question?
This post is also available in: English Українська Portuguese Español Deutsch Chinese Русский Français Italiano Türkçe 日本語 한국어
Leave a Reply