IntradayFlagFormationStrat

Description

The Intraday Flag Formation strategy is an attempt to successfully identify, enter, and exit the well-known Flag pattern on intraday charts. This approach was described by Markos Katsanos in his article "Detecting Flags in Intraday Charts." Although intraday flags have the same geometric principles as daily ones, it is suggested that the former conform to more strict criteria. These apply mostly to the shape of flag elements (the pole and the flag itself) and their duration. You can customize the criteria in the input parameters, however, the current article discusses their default values.

 A simulated entry order is added when the flag is identified and all of the following is true:

  • There is currently no open market position;
  • The flag pole height is at least 5.5 times the average true range (ATR) and its formation takes no longer than 23 bars;
  • The flag itself is not wider than 2.5 times the ATR and its formation takes no longer than 15 bars;
  • There is an uptrend before the flag formation and it persists for at least 70 bars;
  • Previous flag formation (if any) occurred at least 50 bars ago;
  • The ATR has changed by at least 5% during the flag formation;
  • A breakout from the formation occurs.

When there is an open position, the strategy starts seeking exit possibilities. An exit order is added when any of the following is true:

  • Price reaches the profit target equal to 1.2 times the pole;
  • Price reaches the stop loss or the trailing stop loss (both customizable via input parameters);
  • Inactivity period is longer than 70 bars. Inactivity means that the minimum favorable advance is less than 4 times the ATR;
  • None of the above happens for 100 bars since the entry point.

Input Parameters

max flag length The maximum number of bars since the pole top.
max flag height The maximum flag width, expressed in ATRs.
max pole length The maximum duration of the pole formation, in bars.
min pole height The minimum pole length (bottom-to-top), expressed in ATRs.
up trend length The minimum duration of the preceding uptrend, in bars.
min length between flags

The minimum number of bars from the previous flag.

min atr percent change

The minimum ATR percent change during the formation.

strict breakout If set to yes, the breakout is identified when the price grows out of the flag. If no, a bullish bar with close higher than the previous would suffice.
profit target constant The profit target coefficient. The profit target is calculated as the pole top value times this coefficient.
stop loss delay length Defines the length for the stop loss calculation.
stop atr The number of ATRs that defines the stop loss below the flag.
trail stop length

Defines the length for the trailing stop calculation.

trail stop atr The number of ATRs that defines the trailing stop.
inactivity exit length The maximum inactvity duration, in bars.
inactivity atr Defines the multiplier in the inactivity identification.
time exit length Defines the maximum period for the position to be open.

Further Reading

1. "Detecting Flags In Intraday Charts" by Markos Katsanos. Technical Analysis of Stocks & Commodities, December 2014.

You may also like
SwingThree
The Swing Three strategy is a basic momentum/breakout trading system developed by Donald ...
PairTradingLong
The Pair Trading Long strategy is part of Domenico D'Errico's pair trading system. By design, ...