|  | 
| PatternExplorer.com - Fibonacci Recognition 
 _SECTION_BEGIN("Price");
 SetChartOptions(0,chartShowArrows|chartShowDates);
 _N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
 Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
 if( ParamToggle("Tooltip shows", "All Values|Only Prices" ) )
 {
 ToolTip=StrFormat("Open: %g\nHigh:  %g\nLow:   %g\nClose:  %g (%.1f%%)\nVolume: "+NumToStr( V, 1 ), O, H, L, C, SelectedValue( ROC( C, 1 )));
 }
 _SECTION_END();
 
 _SECTION_BEGIN("MA");
 P = ParamField("Price field",-1);
 Periods = Param("Periods", 15, 2, 200, 1 );
 Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
 _SECTION_END();
 
 _SECTION_BEGIN("Mid MA");
 P = ParamField("Price field",-1);
 Periods = Param("Periods", 45, 2, 300, 1 );
 Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
 _SECTION_END();
 
 _SECTION_BEGIN("Long MA");
 P = ParamField("Price field",-1);
 Periods = Param("Periods", 100, 2, 400, 1 );
 Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") | styleNoRescale );
 _SECTION_END();
 
 _SECTION_BEGIN("BBands");
 P = ParamField("Price field",-1);
 Periods = Param("Periods", 15, 2, 300, 1 );
 Width = Param("Width", 2, 0, 10, 0.05 );
 Color = ParamColor("Color", colorLightGrey );
 Style = ParamStyle("Style") | styleNoRescale | styleNoRescale;
 Plot( BBandTop( P, Periods, Width ), "BBTop" + _PARAM_VALUES(), Color, Style );
 Plot( BBandBot( P, Periods, Width ), "BBBot" + _PARAM_VALUES(), Color, Style );
 _SECTION_END();
 
 _SECTION_BEGIN("Volume");
 Plot( Volume, _DEFAULT_NAME(), ParamColor("Color", colorLavender ), styleNoTitle | ParamStyle( "Style", styleHistogram | styleOwnScale | styleThick | styleNoLabel, maskHistogram  ), 2 );
 _SECTION_END();
 
 _SECTION_BEGIN("Price Interpretation");
 movshort = ParamField("Short Time MA", 8 );
 movmed = ParamField("Mid Time MA", 9 );
 movlong = ParamField("Long Time MA", 10 );
 btop = ParamField("BBTop", 11 );
 bbot = ParamField("BBBottom", 12 );
 if( Status("action") == actionCommentary )
 {
 width = btop - bbot;
 lslop = LinRegSlope( C, 30 ) + 100;
 lslo = LLV( lslop, 90 );
 lshi = HHV( lslop, 90 );
 lswidth = lshi - lslo;
 trend = 100*( lslop - lslo )/lswidth;
 
 mawidth = MA( width, 100 );
 relwidth = 100*(width - mawidth)/mawidth;
 
 _N( tname = Name()+"("+FullName()+")" );
 
 printf("Price and moving averages:\n");
 printf( tname + " has closed " + WriteIf( C > movshort, "above" , "below" ) + " its Short time moving average. ");
 
 printf("\nShort time moving average is currently " + WriteIf( movshort > movmed, "above", "below") + " mid-time, AND " + WriteIf( movshort > movlong, "above", "below" ) + " long time moving averages.");
 
 printf("\nThe relationship between price and moving averages is: "+
 WriteIf( C > movshort AND movshort > movmed, "bullish",
 WriteIf( C < movshort AND movshort < movmed, "bearish", "neutral" ) ) + " in short-term, and "+
 WriteIf( movshort > movmed AND movmed > movlong , "bullish",
 WriteIf( movshort < movmed AND movmed < movlong, "bearish", "neutral" ) ) + " in mid-long term. ");
 
 printf("\n\nBollinger Bands:\n");
 printf(tname+ " has closed " +
 WriteIf( C < bbot, "below the lower band by " +
 WriteVal( 100 *( bbot-C )/ width, 1.1 ) + "%%. " +
 WriteIf( trend < 30, " This combined with the steep downtrend can suggest that the downward trend in prices has a good chance of continuing.  However, a short-term pull-back inside the bands is likely.",
 WriteIf( trend > 30 AND trend < 70, "Although prices have broken the lower band and a downside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +
 
 WriteIf( C > btop, "above the upper band by " +
 WriteVal( 100 *( C- btop )/ width, 1.1 ) + "%%. " +
 WriteIf( trend > 70, " This combined with the steep uptrend suggests that the upward trend in prices has a good chance of continuing.  However, a short-term pull-back inside the bands is likely.",
 WriteIf( trend > 30 AND trend < 70, "Although prices have broken the upper band and a upside breakout is possible, the most likely scenario for "+tname+" is to continue within current trading range.", "" ) ), "" ) +
 
 WriteIf( C < btop AND ( ( btop - C ) / width ) < 0.5,
 "below upper band by " +
 WriteVal( 100 *( btop - C )/ width, 1.1 ) + "%%. ",
 WriteIf( C < btop AND C > bbot , "above bottom band by " +
 WriteVal( 100 *( C - bbot )/ width, 1.1 ) + "%%. ", "" ) ));
 
 printf("\n"+
 WriteIf( ( trend > 30 AND trend < 70 AND ( C > btop OR C < bbot ) ) AND abs(relwidth) > 40,
 "This picture becomes somewhat unclear due to the fact that Bollinger Bands are  currently",
 "Bollinger Bands are " )+
 WriteVal( abs( relwidth ), 1.1 ) + "%% " +
 WriteIf( relwidth > 0, "wider" , "narrower" ) +
 " than normal.");
 
 printf("\n");
 
 printf(
 WriteIf( abs( relwidth ) < 40, "The current width of the bands (alone) does not suggest anything conclusive about the future volatility or movement of prices.","")+
 WriteIf( relwidth < -40, "The narrow width of the bands suggests low volatility as compared to " + tname + "'s normal range.  Therefore, the probability of volatility increasing with a sharp price move has increased for the near-term. "+
 "The bands have been in this narrow range for " + WriteVal(BarsSince(Cross(-40,relwidth)),1.0) + " bars. The probability of a significant price move increases the longer the bands remain in this narrow range." ,"")+
 WriteIf( relwidth > 40, "The large width of the bands suggest high volatility as compared to " + tname + "'s normal range.  Therefore, the probability of volatility decreasing and prices entering (or remaining in) a trading range has increased for the near-term. "+
 "The bands have been in this wide range for  " + WriteVal(BarsSince(Cross(relwidth,40)),1.0) + " bars.The probability of prices consolidating into a less volatile trading range increases the longer the bands remain in this wide range." ,""));
 
 printf("\n\nThis commentary is not a recommendation to buy or sell. Use at your own risk.");
 }
 _SECTION_END();
 
 //|-----------------------------------------------------------------------------------------
 //|PatternExplorer.com - Fibonacci Recognition
 //|Copyright c 2007, PatternExplorer.com
 //|http://www.PatternExplorer.com
 //|e-mail: support@PatternExplorer.com
 //|-----------------------------------------------------------------------------------------
 FormulaName = "PE - Fibonacci Recognition";
 
 SetChartOptions( 0, chartShowDates | chartShowArrows | chartLogarithmic | chartWrapTitle );
 #pragma nocache
 #include_once  <\PEInc\PatternExplorer_f0.afl>
 #include_once "C:\Program Files\AmiBroker\Formulas\PatternExplorer\#Defaults & Mods\PE - Defaults.afl"
 #include_once "C:\Program Files\AmiBroker\Formulas\PatternExplorer\#Defaults & Mods\PE - Mods.afl"
 /*******************************************************************************************/
 AddCustomCodeBeforePE();
 /*******************************************************************************************/
 _SECTION_BEGIN( "Main Parameters" );
 AddparamUsefromChart( def_UseFromChart );
 Sensitivity = Param( "Sensitivity", 10, 0, 100, 1 );
 
 if ( InChart )
 StaticVarSet( "P0O3U2", Sensitivity );
 
 if ( inAA AND Usefromchart )
 Sensitivity = StaticVarGet( "P0O3U2" );
 
 Colorstyle = ParamToggle( "Color Mode", "S/R|Custom", 1 );
 
 Color_SL =  ParamColor( "Support (S/R Mode)", def_Color_SL );
 
 Color_RL =  ParamColor( "Resistance (S/R Mode)", def_Color_RL );
 
 _SECTION_END();
 
 /*******************************************************************************************/
 _SECTION_BEGIN( "Levels" );
 
 Level_1p = Param( "Level 1", 38.2, 0, 200, 1 );
 
 Level_2p = Param( "Level 2", 50.0, 0, 200, 1 );
 
 Level_3p = Param( "Level 3", 61.8, 0, 200, 1 );
 
 Level_4p = Param( "Level 4", 138.2, 0, 200, 1 );
 
 Level_5p = Param( "Level 5", 150, 0, 200, 1 );
 
 Level_6p = Param( "Level 6", 161.8, 0, 200, 1 );
 
 Level_7p = Param( "Level 7", 200, 0, 300, 1 );
 
 _SECTION_END();
 
 /*******************************************************************************************/
 _SECTION_BEGIN( "Styles" );
 
 SwingLow_style = ParamStyle( "Swing Low", styleLine + styleDots, maskAll );
 
 SwingHigh_style = ParamStyle( "Swing High", styleLine + styleDots, maskAll );
 
 L1_style = ParamStyle( "Level 1", styleLine + styleDashed, maskAll );
 
 L2_style = ParamStyle( "Level 2", styleLine, maskAll );
 
 L3_style = ParamStyle( "Level 3", styleLine + styleDashed, maskAll );
 
 L4_style = ParamStyle( "Level 4", styleLine + styleDashed, maskAll );
 
 L5_style = ParamStyle( "Level 5", styleLine, maskAll );
 
 L6_style = ParamStyle( "Level 6", styleLine + styleDashed, maskAll );
 
 L7_style = ParamStyle( "Level 7", styleLine + styleThick + styleDots, maskAll );
 
 _SECTION_END();
 
 /*******************************************************************************************/
 _SECTION_BEGIN( "Colors" );
 
 SwingLow_color = ParamColor( "Swing Low", def_SwingLow_color );
 
 SwingHigh_color = ParamColor( "Swing High", def_SwingHigh_color );
 
 L1_color = ParamColor( "Level 1", def_L1_color );
 
 L2_color = ParamColor( "Level 2", def_L2_color );
 
 L3_color = ParamColor( "Level 3", def_L3_color );
 
 L4_color = ParamColor( "Level 4", def_L4_color );
 
 L5_color = ParamColor( "Level 5", def_L5_color );
 
 L6_color = ParamColor( "Level 6", def_L6_color );
 
 L7_color = ParamColor( "Level 7", def_L7_color );
 
 _SECTION_END();
 
 /*******************************************************************************************/
 _SECTION_BEGIN( "Selection" );
 
 L1_switch = ParamToggle( "Plot Level 1", "Off|On", 1 );
 
 L2_switch = ParamToggle( "Plot Level 2", "Off|On", 1 );
 
 L3_switch = ParamToggle( "Plot Level 3", "Off|On", 1 );
 
 L4_switch = ParamToggle( "Plot Level 4", "Off|On", 1 );
 
 L5_switch = ParamToggle( "Plot Level 5", "Off|On", 1 );
 
 L6_switch = ParamToggle( "Plot Level 6", "Off|On", 1 );
 
 L7_switch = ParamToggle( "Plot Level 7", "Off|On", 1 );
 
 _SECTION_END();
 
 /*******************************************************************************************/
 #include_once  <\PEInc\Lib\PatternExplorer_f10.afl>
 #include_once  <\PEInc\PatternExplorer_1.afl>
 /*******************************************************************************************/
 Filter = def_Filter AND BarIndex() == LastValue( BarIndex() ) AND NOT GroupID() == 253;
 
 /*******************************************************************************************/
 Addefaultcolumns();
 
 AddColumn( CurrentRT_EXT, "Current RT/EXT %" );
 
 AddColumn( MaxRT_EXT, "Current max. RT/EXT %" );
 
 AddTextColumn(
 WriteIf( Sup_pricejustabove, "Price just above",
 WriteIf( Sup_confirmed, "Confirmed",
 WriteIf( Sup_break, "Break", "" ) ) ), "Swing Low", 1.2,
 IIf( Sup_pricejustabove OR sup_confirmed, colorGreen, colorRed ) );
 
 AddTextColumn(
 WriteIf( Res_pricejustbelow, "Price just below",
 WriteIf( Res_confirmed, "Confirmed",
 WriteIf( Res_break, "Break", "" ) ) ), "Swing High", 1.2,
 IIf( Res_pricejustbelow OR Res_confirmed, colorRed, colorGreen ) );
 
 AddTextColumn( FullName(), "Full name" );
 
 /*******************************************************************************************/
 Plot( IIf( x >= xa &NOT AnZ, ya, -1e10 ), "", SLcol, 1 + 8 + 2048 );
 
 Plot( IIf( x >= xb &NOT AnZ, yb, -1e10 ), "", SHcol, 1 + 8 + 2048 );
 
 Plot( IIf( x >= xab &NOT AnZ, Level_1, -1e10 ), "", L1col, L1_style + styleNoRescale );
 
 Plot( IIf( x >= xab &NOT AnZ, Level_2, -1e10 ), "", L2col, L2_style + styleNoRescale );
 
 Plot( IIf( x >= xab &NOT AnZ, Level_3, -1e10 ), "", L3col, L3_style + styleNoRescale );
 
 Plot( IIf( x >= xab &NOT AnZ, Level_4, -1e10 ), "", L4col, L4_style + styleNoRescale );
 
 Plot( IIf( x >= xab &NOT AnZ, Level_5, -1e10 ), "", L5col, L5_style + styleNoRescale );
 
 Plot( IIf( x >= xab &NOT AnZ, Level_6, -1e10 ), "", L6col, L6_style + styleNoRescale );
 
 Plot( IIf( x >= xab &NOT AnZ, Level_7, -1e10 ), "", L7col, L7_style + styleNoRescale );
 
 PlotText( WriteIf( L1_switch, "" + Level_1p + " %", "" ), LastValue( BarIndex() + 2 ), Level_1, L1col, colorDefault );
 
 PlotText( WriteIf( L2_switch, "" + Level_2p + " %", "" ), LastValue( BarIndex() + 2 ), Level_2, L2col, colorDefault );
 
 PlotText( WriteIf( L3_switch, "" + Level_3p + " %", "" ), LastValue( BarIndex() + 2 ), Level_3, L3col, colorDefault );
 
 PlotText( WriteIf( L4_switch, "" + Level_4p + " %", "" ), LastValue( BarIndex() + 2 ), Level_4, L4col, colorDefault );
 
 PlotText( WriteIf( L5_switch, "" + Level_5p + " %", "" ), LastValue( BarIndex() + 2 ), Level_5, L5col, colorDefault );
 
 PlotText( WriteIf( L6_switch, "" + Level_6p + " %", "" ), LastValue( BarIndex() + 2 ), Level_6, L6col, colorDefault );
 
 PlotText( WriteIf( L7_switch, "" + Level_7p + " %", "" ), LastValue( BarIndex() + 2 ), Level_7, L7col, colorDefault );
 
 PlotText( "100 %", LastValue( BarIndex() + 2 ), SwingLow, IIf( LastValue( up ), SwingLow_color, SwingHigh_color ), colorDefault );
 
 PlotText( "0 %", LastValue( BarIndex() + 2 ), Swinghigh, IIf( LastValue( dn ), SwingLow_color, SwingHigh_color ), colorDefault );
 
 /*******************************************************************************************/
 ToolTip = def_ToolTip;
 
 /*******************************************************************************************/
 AddCustomCodeAfterPE();
 
 /*******************************************************************************************/
 Title = "PatternExplorer.com - Fibonacci Recognition" + default_priceTitle + EncodeColor( IIf( NOT AnZ, def_Text2, colorRed ) ) + ", Sensitivity = " + WriteVal( Sensitivity, 1 ) + EncodeColor( colorRed ) + WriteIf( NOT AnZ, "", "  NO POINTS AVAILABLE -> REDUCE SENSITIVITY" ) + EncodeColor( IIf( LastValue( L ) > 0, Color_SL, Color_RL ) ) + ", Current Correction = " + WriteVal( CurrentRT_EXT, 1.0 ) + "%     ";
 
 _SECTION_END();
 | 
 |