How XTrail2 Expert Advisor works

Working of XTrail2 Expert

The XTrail2 Expert Advisor scans trade conditions based on two Moving Averages, typically a fast Moving Average and a slow Moving Average. It only provides ALERT message to the user, it DOES NOT open or close trades.

The concept behind the XTrail2 script is that the combination of a fast Moving Average and a slow Moving Average identifies trending markets, especially fast breakouts. It scans for trading opportunities every RUN_INTERVAL seconds, and alerts the user when a BUY or a SELL criteria is met.

The fast Moving Average responds to price quicker than the slow Moving Average. When the market transitions from a sideways movement to a breakout (either bullish or bearish), the fast Moving Average crosses in the slow Moving Average in the direction of the breakout. If this cross is sustained on the next bar, a BULLISH or BEARISH criteria is confirmed and the script generates a BUY or SELL alert respectively.

BUY (BULLISH) ALERT in XTrail2 Expert Advisors

A BUY (BULLISH) alert is generated when the fast Moving Average of the current candle is above its slow Moving Average, AND, the fast Moving Average of the previous candle is also above its slow Moving Average, AND, the fast Moving Average two candles ago is below its slow Moving Average of two candles ago.

In other words, the fast Moving Average has crossed above the slow Moving Average on the previous candle and is continuing its uptrend. This implies that the price has exhibited a bullish breakout recently, and is a potential for BUY trade.

 

SELL (BEARISH) ALERT in XTrail2 Expert Advisors

A SELL (BEARISH) alert is generated when the fast Moving Average of the current candle is below its slow Moving Average, AND, the fast Moving Average of the previous candle is also belwo its slow Moving Average, AND, the fast Moving Average two candles ago is above its slow Moving Average of two candles ago.

In other words, the fast Moving Average has crossed below the slow Moving Average on the previous candle and is continuing its downtrend. This implies that the price has exhibited a bearish breakout recently, and is a potential for SELL trade.

 

Configurable Inputs Parameters of  XTrail2 Expert Advisors

  1. MA1_PERIOD – The period used to calculate the first Moving Average.
  2. MA1_SHIFT – The value number of bars ago of the first Moving Average used in the calculations.
  3. MA1_PRICE – The price field used to calculate the first Moving Average. The supported price fields are – Close = 0, Open = 1, High = 2, Low = 3, Median = 4, Typical = 5, Weighted = 6.
  4. MA1_METHOD – The method used to calculate the first Moving Average. There are four supported methods for calculating the Moving average. These are – SMA = 0, EMA = 1, SMMA = 2 and LWMA = 3.
  5. MA2_PERIOD – The period used to calculate the second Moving Average.
  6. MA2_SHIFT – The value number of bars ago of the second Moving Average used in the calculations.
  7. MA2_PRICE – The price field used to calculate the second Moving Average. The supported price fields are – Close = 0, Open = 1, High = 2, Low = 3, Median = 4, Typical = 5, Weighted = 6.
  8. MA2_METHOD – The method used to calculate the second Moving Average. There are four supported methods for calculating the Moving average. These are – SMA = 0, EMA = 1, SMMA = 2 and LWMA = 3.
  9. RUN_INTERVAL – The interval in seconds when the trade conditions are scanned. For example if this value is 10, then the trade conditions are checked every 10 seconds.