The AIQ code based on Markos Katsanos’ article in Stocks & Commodities magazine, “Detecting Flags In Intraday Charts,” is provided at www.TradersEdgeSystems.com/traderstips.htm, and is also shown here:
!DETECTING FLAGS IN INTRADAY CHARTS !Author: Markos Katsanos, TASC December 2014 !Coded by: Richard Denning 10/18/14 !USER DEFINED FUNCTIONS: C is [close]. Name is description(). !COMPLETED FLAG PATTERN: FLAG is [Flag]. FLAG_breakoutup if FLAG > 0. FLAG_breakoutdn if FLAG < 0. !EMERGING FLAG PATTERN: e_FLAG is [eFLAG]. e_FLAGup if e_FLAG > 0. e_FLAGdn if e_FLAG < 0. !REPORTS TO LIST ALL FLAG PATTERS: ShowAllCompleted if C>0 and FLAG <> 0. ShowAllEmerging if C>0 and e_FLAG <>0.
The AIQ program has a chart-pattern recognition module that operates only in daily mode. I am providing code to find both completed flag patterns and also emerging flag patterns.
In Figure 10, I show a chart of G-III Apparel Group Ltd., which shows a flag pattern completed on June 25, 2014 (green up arrow), when the price broke above the down-sloping flag top. Although the volume was above average on the breakout, the follow through was lacking.
FIGURE 10: AIQ. This sample chart shows G-III Apparel Group Ltd. (GIII) with a completed flag pattern (indicated by the green up arrow).
Note that I did not code exits for the pattern, as the built-in exits can be used to experiment with the flag pattern entry. Note also that the AIQ version of flags does not match exactly the intraday flags that are defined by Katsanos in his article.