TS8 Radarscreen Pennant Brkout UP

Discussion in 'Strategy Development' started by mokwit, Mar 13, 2007.

  1. Can some one please post the code for this [Pennant Brkout UP] indicator for Radarscreen. I am running TS2000i so an ELD won't cut it - need it in text form so I can cut and past into PowerEditor and make any changes necessary to convert to TS2000i. It's supposed to be posted on the forum but in ELD format and I could not find it.

    PM me with it if you don't want Los hermanos Cruz to see.
     
  2. Aw, c'mon, someone must have it. Just a quick copy and paste would really help me.

    WRT to intellectual property, as far as I am aware this indicator is based on the code in an article on scanning for pennants by Marcos Katsanos in TASC. He provided the Metastock code and in other articles of his TS provided the TS code, but with this particular one for some reason did not (missed deadline?).
     
  3. skepticaltrader

    skepticaltrader Guest

    Code:
    {
    1. NOT DESIGNED TO UPDATE AT EVERY TICK.
    2. CAN BE USED AS A VALIDATION TOOL FOR THE RADARSCREEN INDICATORS: 
    		PENNANT BRKOUT UP
    		PENNANT BRKOUT DN
    
    This ShowMe will draw each pennant formation identified, and also plot the up or down 
    breakout from each pennant, whichever comes first, if it occurs within BarsPast bars 
    of the completion of the pennant.  Pennant extensions for the BarsPast bars are 
    plotted as points.  The breakouts are plotted as cross ShowMe's.
    
    If a new pennant is identified within BarsPast bars of the previous pennant, the new 
    pennant supersedes the previous pennant, but if pennant graphics are being drawn 
    (DrawLines = true ), the previous pennant graphics are not removed.  If there is a 
    breakout from the most recent pennant within BarsPast bars of its completion, plotted 
    as a ShowMe, the pennant lines are drawn in a wider width.  This helps to distinguish 
    it from any other pennants nearby.
    
    For more information about how the Pennant function works, please refer to the in-line 
    documentation included in the function code.
    }
    
    inputs:
    	Length( 7 ), 
    	MaxConsolIndex( 1.5 ), 
    	BarsPast( 5 ), 
    	DrawLines( true ), 
    	DrawExtensions( true ), 
    	Color1( Red ), 
    	Color2( Magenta ) ; { Color1 and Color2 are used in an alternating fashion each 
    	 time a new pennant is found }
    
    variables: 
    	LengthMinus1( Length - 1 ), 
    	oTLHiStartPr( 0 ), 
    	oTLHiEndPr( 0 ), 
    	oTLLoStartPr( 0 ), 
    	oTLLoEndPr( 0 ), 
    	Color( Color2 ), 
    	TLHi( 0 ), 
    	TLLo( 0 ) ;
    
    Value1 = Pennant( Length, MaxConsolIndex, BarsPast, oTLHiStartPr, oTLHiEndPr, 
     oTLLoStartPr, oTLLoEndPr ) ;
    
    if Value1 = 1 then 
    	begin 
    	{ switch to alternate color }
    	if Color = Color2 then
    		Color = Color1
    	else
    		Color = Color2 ;
    	if DrawLines then 
    		begin 
    		TLHi = TL_New( Date[LengthMinus1], Time[LengthMinus1], oTLHiStartPr, Date, 
    		 Time, oTLHiEndPr ) ;
    		TL_SetExtLeft( TLHi, false ) ;
    		TL_SetExtRight( TLHi, false ) ;
    		TL_SetColor( TLHi, Color ) ;
    		TLLo = TL_New( Date[LengthMinus1], Time[LengthMinus1], oTLLoStartPr, Date, 
    		 Time, oTLLoEndPr ) ;
    		TL_SetExtLeft( TLLo, false ) ;
    		TL_SetExtRight( TLLo, false ) ;
    		TL_SetColor( TLLo, Color ) ;
    		end ;
    	end 
    else if Value1 = 2 or Value1 = 3 then 
    	begin 
    	if DrawLines then 
    		begin 
    		TL_SetSize( TLHi, 2 ) ;
    		TL_SetSize( TLLo, 2 ) ;
    		end ;
    	if Value1 = 2 then 
    		Plot1( High, "PenBrkoutUp" ) 
    	else if Value1 = 3 then 
    		Plot2( Low, "PenBrkoutDn" ) ;
    	end ;
    if DrawExtensions then 
    	begin 
    	if oTLHiEndPr > 0 then 
    		Plot3( oTLHiEndPr, "HiExt", Color ) ;
    	if oTLLoEndPr > 0 then 
    		Plot4( oTLLoEndPr, "LoExt", Color ) ;
    	end ;
    
    
    { ** Copyright (c) 1991-2003 TradeStation Technologies, Inc. All rights reserved. ** 
      ** TradeStation reserves the right to modify or overwrite this analysis technique 
         with each release. ** }
    
    
     
  4. Code:
    { 
    Grid indicator.  Apply to intraday data.
    
    This indicator will trigger an alert, in real time, at the bar that makes the first 
    upside breakout from the pennant if a downside breakout does not occur first.
    
    INDICATOR PLOTS
    Column1 - HiLine: Starting with the bar that a pennant is confirmed on, and 
     continuing for a total of up to BarsPast bars, this column displays the value of the 
     high-line of the pennant at that bar.  This value is updated at each bar of the 
     BarsPast period as the high-line is extended to the right, and sets the trigger for 
     the Pennant Brkout Up alert for the next bar.  Starting with the bar after an alert 
     is triggered, Column1 switches to a display of the number of bars that have elapsed 
     since the alert, with a negative sign.  This second display continues until 
     ColorBars bars have elapsed, at which time (or at the end of BarsPast bars if there 
     was no alert) the display turns blank again until the next pennant is identified.
    
    For more information on how this indicator works, please refer to the in-line 
    documentation included in the companion ShowMe "Pennant Brkout".
    }
    
    inputs:
    	Length( 7 ), { number of bars in pennant }
    	MaxConsolIndex( 1.5 ), { enter a value in the 1-to-Length range; the lower this 
    	 value, the tighter the consolidation pattern }
    	BarsPast( 5 ), { the indicator will look for a pennant breakout for this many 
    	 bars after the pennant is identified }
    	AlertFGColor( Black ),
    	AlertBGColor( Yellow ),
    	PlotBars( 5 ), { number of bars on which to display a value in cell once pennant
    	 is confirmed }
    	ColorBars( 5 ) ; { number of bars the alert colors will persist; set to 0 for no
    	 cell alert coloring }
    
    variables: 
    	oTLHiStartPr( 0 ), 
    	oTLHiEndPr( 0 ), 
    	oTLLoStartPr( 0 ), 
    	oTLLoEndPr( 0 ),
    	BarNum( 0 ), 
    	AlertBarNum( 0 ), 
    	BarsSinceAlert( 0 ), 
    	PlotThisBar( false ), 
    	ColorThisBar( false ) ;
    
    Value1 = Pennant( Length, MaxConsolIndex, BarsPast, oTLHiStartPr, oTLHiEndPr, 
     oTLLoStartPr, oTLLoEndPr ) ;
    
    BarNum = BarNumber ;
    if Value1 = 2 then 
    	begin 
    	Alert( "Pennant brkout up" ) ;
    	AlertBarNum = BarNum ;
    	end ;
    
    BarsSinceAlert = BarNum - AlertBarNum ;
    PlotThisBar = AlertBarNum > 0 and BarsSinceAlert < PlotBars + 1 ;
    ColorThisBar = ColorBars > 0 and BarsSinceAlert < ColorBars + 1 ;
    	
    if PlotThisBar and BarsSinceAlert > 0 then 
    	begin
    	Plot1( -BarsSinceAlert, "HiLine" ) ; 
    	if ColorThisBar then 
    		begin 
    		SetPlotColor( 1, AlertFGColor ) ;
    		SetPlotBGColor( 1, AlertBGColor ) ;
    		SetPlotColor( 2, AlertFGColor ) ;
    		SetPlotBGColor( 2, AlertBGColor ) ;
    		end ;
    	end
    else if oTLHiEndPr > 0 then 
    	begin
    	Plot1( oTLHiEndPr, "HiLine" ) ;
    	if ColorThisBar then 
    		begin 
    		SetPlotColor( 1, AlertFGColor ) ;
    		SetPlotBGColor( 1, AlertBGColor ) ;
    		SetPlotColor( 2, AlertFGColor ) ;
    		SetPlotBGColor( 2, AlertBGColor ) ;
    		end ;
    	end ;
    
    
    
     
  5. Skepticaltrader, thanks, very much appreciated but it is the Radarscreen version that I really need and from what you posted it would seem that I need the function code as well.

    Nana, do you have the accompanying function code (which I suspect is needed - but i could be wrong)
     
  6. I think the function code is in a function called pennant - just tried to verify Nana's code and 'pennant' in the body of Nana's code was flagged as not recognised by easylanguage - suggesting it is a missing function.
     
  7. The code above from TS8.2, they always do some changes to some indicators from version to version and may be function not there in TS2000i. check PM
     
  8. Nana, thanks, that is exactly it.
     
  9. skepticaltrader

    skepticaltrader Guest

    Does this help?





    Pennant (Series Function)
    Disclaimer

    For the purposes of this study, a pennant is defined as a converging consolidation pattern on a bar chart. This includes cases where the two straight lines bounding the pattern's highs and lows are sloping in opposite directions as well as in the same direction, as long as they are converging. The limiting case of when the two lines are parallel is included. Note that this definition automatically includes certain consolidation patterns that may otherwise be known as "flags".



    Algorithm

    Check if the Consolidation Index (True Price Channel/Average True Range) is low enough (i.e., < MaxConsolIndex) to indicate a significant degree of price consolidation. ConsolIndex values can range between 1 and Length. Low values indicate price consolidation, high values indicate price extension. To identify reasonable consolidation patterns, some suitable combinations of Length/ MaxConsolIndex could be 7/1.5 and 15/2. (Also see the RS_PriceExtension function, which looks for high values of ConsolIndex.)

    If price consolidation is confirmed, outline the pattern by "drawing" a linear regression line through the pattern's highs and a second such line through the pattern's lows, and check if the lines are converging.

    If the lines are converging, a pennant exists; finish defining the pennant by shifting the lines outwards as much as necessary to fully enclose all the bars in the consolidation pattern.

    For the next BarsPast bars, or until the pennant converges, whichever comes first, look for the price to breakout of the pennant, up or down, whichever comes first. (Simultaneous up and down breakouts are ignored.)





    Usage

    Value1 = PennantLength, MaxConsolIndex, BarsPast, oTLHiStartPr, oTLHiEndPr, oTLLoStartPr, oTLLoEndPr);





    Returns

    1 if a pennant has just been identified. (The start and end prices of the defining lines are returned as outputs.)

    2 if the price has broken out above the most recently completed pennant within the previous BarPast bars.

    3 if the price has broken out below the most recently completed pennant within the previous BarPast bars.

    -1 if none of the above.



    Parameters

    Length
    (Input) The number of bars in the pennant.

    MaxConsolIndex
    (Input) See algorithm step 1 above.

    BarPast
    (Input) See algorithm step 4 above.

    oTLHiStartPr
    (Output) Start price of current pennant’s hi-line.

    oTLHiEndPr
    (Output) End price of current pennant’s hi-line (this continues to be updated for BarsPast bars after the pennant is confirmed).

    oTLLoStartPr
    (Output) Start price of current pennant’s lo-line.

    oTLLoEndPr
    (Output) End price of current pennant’s lo-line (this continues to be updated for BarsPast bars after the pennant is confirmed).






    Remarks

    If a new pennant is identified within BarsPast bars of the previous pennant, the new pennant supersedes the previous pennant.



    Example

    inputs: Length(7), MaxConsolIndex(1.5), BarsPast(5) ;

    variables: oTLHiStartPr(0), oTLHiEndPr(0), oTLLoStartPr(0), oTLLoEndPr(0) ;

    Value1 = Pennant(Length, MaxConsolIndex, BarsPast, oTLHiStartPr, oTLHiEndPr, oTLLoStartPr, oTLLoEndPr) ;

    Plot1(Value1) ;
     
  10. Yes it does help, but it is not the actual function - it is the explanatory notes - just being accurate here, not ungrateful :)
     
    #10     Apr 8, 2007