Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Exp_XPeriodCandle_X2 - MetaTrader 5 Expert - MT4/MT5 Resources

author EAcpu | 3 reads | 0 comments |

Exp_XPeriodCandle_X2 - expert for MetaTrader 5

Exp_XPeriodCandle_X2 - expert for MetaTrader 5

Trend Following Trading System Exp_XPeriodCandle_X2 Signal XPerod Candle based on two indicators. The first indicator determines the direction of the slow trend based on the color of the indicator's last closing candlestick. The second indicator determines the moment at which trading begins when the color of the candlestick changes. A signal is formed when the bar closes if two conditions are met:

//+------------------------------------------------+
//|Input parameters of EA indicator|
//+------------------------------------------------+
Enter String Trade = "Trade Management" ; //+============== Trade Management==============+
Enter double MM= 0.1 ; //Share of deposit in a transaction
Enter the margin mode MMMode=LOT; //Lot size detection method
Input unit Stop loss_= 1000 ; //Stop loss points
Input unit profit_= 2000 ; //Profit in points
Input string must be traded = "Trade License" ; //+============== Trade License==============+
Enter integer Deviation_= 10 ; //Maximum price deviation (in points)
Enter Boolean BuyPosOpen= True ; //Allow entry into long position
Enter a Boolean value SELL OPEN = TRUE ; //Allow short positions to be opened
//+------------------------------------------------+
//|Input parameters for filtering indicators |
//+------------------------------------------------+
input string filter = "slow trend parameter" ; //+============== trend parameter==============+
Input ENUM_TIMEFRAMES time range = PERIOD_H6 ; //1 chart period of the trend
Input unit period = 5 ; // Calculation period of candle chart
Enter Smooth_Method MA_SMethod=MODE_JJMA; // Average method
Input integer MA_length = 3 ; // smoothing depth
Input integer MA_Phase = 100 ; // Smoothing parameter,
3//---- For JJMA, in the range of -100...+100, it will affect the quality of the transition process;
//----For VIDIA, it is the CMO cycle, for AMA, it is the slow average cycle
Input unit signal field = 1 ; // Number of bars to receive entry signals
Enter boolean Buy Close = true ; // Allow closing positions on trend
Enter a Boolean value Sell transaction close = true ; // Allow closing positions according to trend
//+------------------------------------------------+
//|Input parameters of the entry indicator |
//+------------------------------------------------+
input string input = "input parameter" ; //+================ input parameter==============+
Enter ENUM_TIMEFRAMES time range_= PERIOD_M30 ; //2 chart period for entry
Input unit period_= 5 ; // Calculation period of candle chart
Enter Smooth_Method MA_SMethod_=MODE_JJMA; // Average method
Input integer MA_length_=class="number">3; // Smoothing depth input integer MA_phase_= 100 ; // Smoothing parameter, 3 //---- For JJMA, in the range -100 ... +100, it affects the quality of the transition process; //---- For VIDIA it is the CMO period, for AMA the slow average period input unit signal column_= 1 ; // Number of bars to receive entry signals input Boolean BuyPosClose_= wrong ; // Allow closing of long positions via signals Enter Boolean Sell PosClose_= False ; // Allow closing of short positions via signals //+------------------------------------------------+

String parameters with text in the input parameter code are just for better visualization of the expert's input parameters window.

The indicator XPeriodCandle_HTF in the EA is designed only for easier visualization of trends in the strategy tester; and they do not work in any other mode.

In order for the generated EA to run correctly, the compiled indicator files XPeriodCandle.ex5 and XPeriodCandle_HTF.ex5 must be in the <terminal data directory>\MQL5\indicator folder.

Please note that the Trade Algorithms .mqh library file allows trading Expert Advisors with non-zero spreads and the option to set Stop Loss and Take Profit along with opening positions with brokers that offer the following services.

The input parameters of the default Expert Advisor were used in the test shown below. Stop Loss and Take Profit were not used during testing.

The 2016 XAUUSD test results show that the daily trend is slow, but the entry trend is fast in the first half of the year:

Exp_XPeriodCandle_X2 - expert for MetaTrader 5

Figure 1. Example of trade on chart

Exp_XPeriodCandle_X2 - expert for MetaTrader 5

Figure 2. Test result graph


Attachment download

📎 Exp_XPeriodCandle_X2.mq5 (22.71 KB)

📎 SmoothAlgorithms.mqh (130.2 KB)

📎 TradeAlgorithms.mqh (223.62 KB)

📎 XPeriodCandle.mq5 (16.76 KB)

📎 XPeriodCandle_HTF.mq5 (19.48 KB)

Source: MQL5 #21144

Verification code Refresh