Watch how to download trading robots for free
Find us on Facebook!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Views:
3269
Rating:
(15)
Published:
2017.08.10 12:41
Updated:
2023.03.29 13:48
\MQL5\Experts\ \MQL5\Include\ \MQL5\Indicators\
XROC2_VG.mq5 (19.84 KB) view
XROC2_VG_HTF.mq5 (25.43 KB) view
Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

The Exp_XROC2_VG_X2 trend-following trading system is based on the signals generated by two XROC2_VG indicators. The first indicator determines the direction of the slow trend based on the position of the main and signal lines. The second indicator determines the moment for opening a trade, when the lines are crossed or touched. An entry signal is generated at a bar closure if the following two conditions are met:

  1. Fast and slow trend signals coincide;
  2. Fast trend has changed its direction.

EA inputs:

//+-------------------------------------------------+
//| Input parameters of the EA indicator            |
//+-------------------------------------------------+
input string Trade="Trade management";    //+================ TRADE MANAGEMENT ================+  
input double MM=0.1;               //Share of a deposit in a deal
input MarginMode MMMode=LOT;      //Lot value detection method
input uint    StopLoss_=1000;      //Stop Loss in points
input uint    TakeProfit_=2000;    //Take Profit in points
input string MustTrade="Trade permissions";    //+=============== TRADE PERMISSIONS ===============+  
input int    Deviation_=10;       //Max price deviation in points
input bool   BuyPosOpen=true;     //Permission to enter long positions
input bool   SellPosOpen=true;    //Permission to enter short positions
//+-------------------------------------------------+
//| Input parameters of the filter indicator        |
//+-------------------------------------------------+
input string Filter="SLOW TREND PARAMETERS";    //+============== TREND PARAMETERS ==============+  
input ENUM_TIMEFRAMES TimeFrame=PERIOD_H6;  //1 Chart period for the trend

input uint ROCPeriod1=8;
input Smooth_Method MA_Method1=MODE_JJMA;          //Method of averaging of the first indicator
input uint Length1=5;                              //The depth of the first smoothing                    
input int Phase1=15;                               //The parameter of the first smoothing,
//---- for JJMA within the range of -100 ... +100, it influences the quality of the transition process;
//---- for VIDIA it is a CMO period, for AMA it is a slow average period
input uint ROCPeriod2=14;
input Smooth_Method MA_Method2=MODE_JJMA;          //Method of averaging of the second indicator
input uint Length2 = 5;                            //The depth of the second smoothing 
input int Phase2=15;                               //The parameter of the second smoothing,
//---- for JJMA within the range of -100 ... +100, it influences the quality of the transition process;
//---- for VIDIA it is a CMO period, for AMA it is a slow average period
input ENUM_TYPE ROCType=MOM;

input uint SignalBar=1; //Bar index to receive the entry signal
input bool   BuyPosClose=true;     //Permission to exit long positions by trend
input bool   SellPosClose=true;    //Permission to exit short positions by trend
//+-------------------------------------------------+
//| Input parameters of the entry indicator         |
//+-------------------------------------------------+
input string Input="ENTRY PARAMETERS";       //+=============== ENTRY PARAMETERS ==============+  
input ENUM_TIMEFRAMES TimeFrame_=PERIOD_M30;  //2 Chart period for entry

input uint ROCPeriod1_=8;
input Smooth_Method MA_Method1_=MODE_JJMA;          //Method of averaging of the first indicator 
input uint Length1_=5;                              //The depth of the first smoothing                    
input int Phase1_=15;                               //The parameter of the first smoothing,
//---- for JJMA within the range of -100 ... +100, it influences the quality of the transition process;
//---- for VIDIA it is a CMO period, for AMA it is a slow average period
input uint ROCPeriod2_=14;
input Smooth_Method MA_Method2_=MODE_JJMA;          //Method of averaging of the second indicator 
input uint Length2_ = 5;                            //The depth of the second smoothing 
input int Phase2_=15;                               //The parameter of the second smoothing,
//---- for JJMA within the range of -100 ... +100, it influences the quality of the transition process;
//---- for VIDIA it is a CMO period, for AMA it is a slow average period
input ENUM_TYPE ROCType_=MOM;

input uint SignalBar_=1;//Bar index to receive an entry signal
input bool   BuyPosClose_=false;     //Permission to exit long positions by signal
input bool   SellPosClose_=false;    //Permission to exit short positions by signal

String variable containing the text in the code of input parameters are only used for better visualization of the EA input parameters window.

The XROC2_VG_HTF indicators in the EA are only intended for a more convenient visualization of trends in the strategy tester, in other operation modes they are inactive.

In order to provide proper operation of the compiled Expert Advisor, you should add the compiled XROC2_VG.ex5 and XROC2_VG_HTF.ex5 indicator files to <terminal_data _folder>\MQL5\Indicators.

Note that the TradeAlgorithms.mqh library file allows using Expert Advisors with brokers who offer nonzero spread and the option of setting Stop Loss and Take Profit during position opening. You can download more variants of the library at the following link: Trade Algorithms.

Default input parameters of the Expert Advisor were used during the tests shown below. Stop Loss and Take Profit were not used during testing.

Fig. 1. Examples of deals on the chart


Fig. 1. Examples of deals on the chart

Testing results for 2015 on AUDUSD, slow trend on H6, entry by fast trend on M30:

Fig. 2. Testing results chart

Fig. 2. Testing results chart

Translated from Russian by MetaQuotes Ltd.
Original code: https://www.mql5.com/ru/code/18526

Swing_line_HTF Swing_line_HTF

The Swing_line indicator with the timeframe selection option available in input parameters.

Exp_XROC2_VG_Tm Exp_XROC2_VG_Tm

The Exp_XROC2_VG_Digit_Tm Expert Advisor trades based on signals generated by the XROC2_VG oscillator.

PIPQind PIPQind

This is a trend indicator

Color_QEMA_Digit_HTF Color_QEMA_Digit_HTF

The Color_QEMA_Digit indicator with the timeframe selection option available in input parameters.