Gartleykiran
“Gartleykiran” doesn’t appear to be a widely recognized term in trading or finance. It might refer to a specific trading strategy, indicator, or individual’s name within a proprietary system or context not commonly known in the trading community. These descriptions provide insights into utilizing Gann-related concepts and techniques within Amibroker AFL, along with the integration of Amibroker data feed, to enhance trading analysis and decision-making.
/_SECTION_BEGIN("GartleyKiranB"); // Gartley 222 Pattern Indicator Plot // // Ported by Daniel Ervi from code originally posted for Wealth-Lab by Mark Conway. // Based on the August 2003 article in Active Trader Magazine. // // Usage: Gartley222(VPFactor, Tolerance, Lookback) // VPFactor adjusts swing size percentage (Zig Zag) // Tolerance adjusts percentage tolerance from ideal pattern specification // Lookback adjusts volatility calculation //Global variables, used for Exploration BuyFilter = False; SellFilter = False; // Params VPF = Param("VPFactor (ZIG)", 1.0, 0.1, 25, 0.1); Tol = Param("Tolerance", 0.3, 0, 1, 0.01); LB = Param("Volatility Lookback", 2, 1, BarCount, 1); // Alter Bar counts for performance StartBar = Param("Start Bar", IIf(BarCount>1000, BarCount-1000, 0), 0, BarCount-1, 1); procedure Gartley222(VPFactor, Tolerance, Lookback, StartBar) { F1 = 0.618; F2 = 0.786; F3 = 1.27; F4 = 1.618; // Setup volatility adjusted reversal array VP = 100 * ATR(Lookback) / Close; Reversal = int(VPFactor * VP); for(Bar = StartBar; Bar < BarCount; Bar++) { // Build Peak and Trough arrays P1 = Peak(High, Reversal[Bar]); P1Bar = Bar - PeakBars(High, Reversal[Bar]); P2 = Peak(High, Reversal[Bar], 2); P2Bar = Bar - PeakBars(High, Reversal[Bar], 2); T1 = Trough(Low, Reversal[Bar]); T1Bar = Bar - TroughBars(Low, Reversal[Bar]); T2 = Trough(Low, Reversal[Bar], 2); T2Bar = Bar - TroughBars(Low, Reversal[Bar], 2); // Test for a bullish 222 // Trough X is T2 // Peak A is P2 // Trough B is T1 // Peak C is P1 // D is the Buy point D = Low[Bar];//Bullish Co=ColorRGB(100,100,100); PTValid = (P1Bar[Bar] > T1Bar[Bar]) AND (T1Bar[Bar] > P2Bar[Bar]) AND (P2Bar[Bar] > T2Bar[Bar]); HLValid = (P1[Bar] < P2[Bar]) AND (T1[Bar] > T2[Bar]) AND (P1[Bar] > T1[Bar]); InZone = (D < T1[Bar]) AND (D > T2[Bar]); if(PTValid AND HLValid AND InZone) { XA = P2[Bar] - T2[Bar]; AB = P2[Bar] - T1[Bar]; BC = P1[Bar] - T1[Bar]; CD = P1[Bar] - D; AD = P2[Bar] - D; ABdXA = AB / XA; // AB should be 61.8% of XA C1 = (ABdXA > F1 - Tolerance) AND (ABdXA < F1 + Tolerance); BCdAB = BC / AB; // BC should be 61.8-78.6% of AB C2 = (BCdAB > F1 - Tolerance) AND (BCdAB < F2 + Tolerance); CDdBC = CD / BC; // CD should be 127-161.8% of BC} C3 = (CDdBC > F3 - Tolerance) AND (CDdBC < F4 + Tolerance); ADdXA = AD / XA; // AD should be 78.6% of XA} C4 = (ADdXA > F2 - Tolerance) AND (ADdXA < F2 + Tolerance); if(C1 AND C2 AND C3 AND C4) { // Bullish Gartley found. Draw pattern. PlotXA = LineArray(T2Bar[Bar], T2[Bar], P2Bar[Bar], P2[Bar]); Plot(PlotXA, "", colorBrightGreen, styleLine + styleThick); PlotAB = LineArray(P2Bar[Bar], P2[Bar], T1Bar[Bar], T1[Bar]); Plot(PlotAB, "", colorBrightGreen, styleLine + styleThick); PlotBC = LineArray(T1Bar[Bar], T1[Bar], P1Bar[Bar], P1[Bar]); Plot(PlotBC, "", colorBrightGreen, styleLine + styleThick); PlotCD = LineArray(P1Bar[Bar], P1[Bar], Bar, D); Plot(PlotCD, "", colorBrightGreen, styleLine + styleThick); PlotBD = LineArray(T1Bar[Bar], T1[Bar], Bar, D); Plot(PlotBD, "", colorBrightGreen, styleSwingDots ); PlotXD = LineArray(T2Bar[Bar], T2[Bar], Bar, D); Plot(PlotXD, "", colorBrightGreen, styleSwingDots ); PlotXB = LineArray(T2Bar[Bar], T2[Bar], T1Bar[Bar], T1[Bar]); Plot(PlotXB, "", colorBrightGreen, styleSwingDots ); BuyFilter[Bar]=1; } } // Test for a bearish 222 // Peak X is P2 // Trough A is T2 // Peak B is P1 // Trough C is T1 // D is the Buy point D = High[Bar];//Bearish PTValid = (T1Bar[Bar] > P1Bar[Bar]) AND (P1Bar[Bar] > T2Bar[Bar]) AND (T2Bar[Bar] > P2Bar[Bar]); HLValid = (T1[Bar] > T2[Bar]) AND (P1[Bar] < P2[Bar]) AND (T1[Bar] < P1[Bar]); InZone = (D > P1[Bar]) AND (D < P2[Bar]); if(PTValid AND HLValid AND InZone) { XA = P2[Bar] - T2[Bar]; AB = P1[Bar] - T2[Bar]; BC = P1[Bar] - T1[Bar]; CD = D - T1[Bar]; AD = D - T2[Bar]; ABdXA = AB / XA; // AB should be 61.8% of XA C1 = (ABdXA > F1 - Tolerance) AND (ABdXA < F1 + Tolerance); BCdAB = BC / AB; // BC should be 61.8-78.6% of AB C2 = (BCdAB > F1 - Tolerance) AND (BCdAB < F2 + Tolerance); CDdBC = CD / BC; // CD should be 127-161.8% of BC} C3 = (CDdBC > F3 - Tolerance) AND (CDdBC < F4 + Tolerance); ADdXA = AD / XA; // AD should be 78.6% of XA} C4 = (ADdXA > F2 - Tolerance) AND (ADdXA < F2 + Tolerance); if(C1 AND C2 AND C3 AND C4) { // Bearish Gartley found. Draw pattern. PlotXA = LineArray(P2Bar[Bar], P2[Bar], T2Bar[Bar], T2[Bar]); Plot(PlotXA, "", colorRed, styleLine + styleThick); PlotAB = LineArray(T2Bar[Bar], T2[Bar], P1Bar[Bar], P1[Bar]); Plot(PlotAB, "", colorRed, styleLine + styleThick); PlotBC = LineArray(P1Bar[Bar], P1[Bar], T1Bar[Bar], T1[Bar]); Plot(PlotBC, "", colorRed, styleLine + styleThick); PlotCD = LineArray(T1Bar[Bar], T1[Bar], Bar, D); Plot(PlotCD, "", colorRed, styleLine + styleThick); PlotBD = LineArray(P1Bar[Bar], P1[Bar], Bar, D); Plot(PlotBD, "", colorDarkRed, styleSwingDots ); PlotXD = LineArray(P2Bar[Bar], P2[Bar], Bar, D); Plot(PlotXD, "", colorDarkRed, styleSwingDots ); PlotXB = LineArray(P2Bar[Bar], P2[Bar], P1Bar[Bar], P1[Bar]); Plot(PlotXB, "", colorDarkRed, styleSwingDots ); SellFilter[Bar]=1; } } } } Gartley222(VPF, Tol, LB, StartBar); Filter = IIf(BuyFilter OR SellFilter, 1, Null) ; Color = IIf(BuyFilter, colorGreen, colorRed); AddColumn( IIf(BuyFilter,1,IIf(SellFilter,-1,Null)),"Action",1.0,colorWhite, Color); Plot(C,"Close", colorBlueGrey, styleBar); _SECTION_END();