Elder Triple Screen Trading System..afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:11k
源码类别:
金融证券系统
开发平台:
Others
- //------------------------------------------------------------------------------
- //
- // Formula Name: Elder Triple Screen Trading System.
- // Author/Uploader: Dennis Skoblar
- // E-mail: DennisAndLisa@sbcglobal.net
- // Date/Time Added: 2006-01-27 02:07:40
- // Origin: Derrived from "Trading For A Living" and "Come Into My Trading Room" by Alexander Elder.
- // Keywords: Elder Triple Screen Trading System
- // Level: medium
- // Flags: system,exploration,indicator
- // Formula URL: http://www.amibroker.com/library/formula.php?id=582
- // Details URL: http://www.amibroker.com/library/detail.php?id=582
- //
- //------------------------------------------------------------------------------
- //
- // This scan finds candidates by the Weekly MACD Historgam slope, and the
- // Daily 2 Period Force Index dipping above or below it's Zero Line. Plot a
- // Weekly 26 Period EMA to
- //
- // help confirm the weekly direction. It should be rising along with an uptick
- // on the Weekly MACD Histogram to go long. However, Elder writes that
- // divergences in the MACD
- //
- // Histogram override the EMA. The Daily 2 Period Force Index will be below
- // it's Zero Line. Look for the stock to pullback to around it's Daily 13
- // Period EMA. Also use the
- //
- // Daily 22 Period EMA to confirm the direction of the daily trend. Do the
- // opposite for shorts. Use the Long/Short EMA Weekly Direction Tabs as
- // filters to cull through the
- //
- // scan to only display the Weekly EMA going in the intended trading
- // direction. Use the Long/Short Elder Ray Tabs (BullPower AND BearPower) to
- // fine tune the entry signals.
- //
- // This tab is best used when in agreement with the Long/Short EMA Weekly
- // Direction Tabs. A 50 Period EMA > 100000 is used to Filter Volume. A
- // minimum of a 5 point run in
- //
- // one Month is used as a Filter for a stock's range. This scan is best used
- // as an Exploration.
- //
- //------------------------------------------------------------------------------
- // Elder Triple Screen Trading System.
- // Coded by Dennis Skoblar 7/05/2005.
- // Derrived from "Trading For A Living" and "Come Into My Trading Room" by Alexander Elder.
- // This scan finds candidates by the Weekly MACD Historgam slope, and the Daily 2 Period Force Index dipping above or below it's Zero Line. Plot a Weekly 26 Period EMA to
- // help confirm the weekly direction. It should be rising along with an uptick on the Weekly MACD Histogram to go long. However, Elder writes that divergences in the MACD
- // Histogram override the EMA. The Daily 2 Period Force Index will be below it's Zero Line. Look for the stock to pullback to around it's Daily 13 Period EMA. Also use the
- // Daily 22 Period EMA to confirm the direction of the daily trend. Do the opposite for shorts. Use the Long/Short EMA Weekly Direction Tabs as filters to cull through the
- // scan to only display the Weekly EMA going in the intended trading direction. Use the Long/Short Elder Ray Tabs (BullPower AND BearPower) to fine tune the entry signals.
- // This tab is best used when in agreement with the Long/Short EMA Weekly Direction Tabs. A 50 Period EMA > 100000 is used to Filter Volume. A minimum of a 5 point run in
- // one Month is used as a Filter for a stock's range. This scan is best used as an Exploration.
- TimeFrameSet( inWeekly );
- WeeklyMACD = MACD(12,26) - Signal(12,26,9);
- WeekHistRising = Ref(WeeklyMACD, -1) < Ref(WeeklyMACD, 0);
- WeekHistFalling = Ref(WeeklyMACD, -1) > Ref(WeeklyMACD, 0);
- FIWeekly = EMA(V*(C-Ref(C,-1)),13);
- WeeklyForceIndexLong = FIWeekly > 0;
- WeeklyForceIndexShort = FIWeekly < 0;
- TimeFrameRestore();
- // Weekly criteria
- MACDLongW = WeekHistRising;
- MACDShortW= WeekHistFalling;
- FILongW = WeeklyForceIndexLong;
- FIShortW = WeeklyForceIndexShort;
- // Daily criteria
- FIDaily = EMA(V*(C-Ref(C,-1)),2);
- FILongD = FIDaily < 0;
- FIShortD = FIDaily > 0;
- VFilter = EMA(V,50) > 100000;
- TenTwentyFilter = HHV(H,20)-LLV(L,20); // How much price has gone in one month (>=10 points preferable)
- FiftyDayHVFilter = round(StDev(log(C/Ref(C,-1)),50)*100*sqrt(256)); // One year volotility (>=40 preferable)
- bullpower= High - EMA(Close,13);
- bearpower= Low - EMA(Close,13);
- // Scan criteria
- ElderLong = MACDLongW AND FILongD AND FILongW;
- ElderShort = MACDShortW AND FIShortD AND FIShortW;
- // Columns for exploration
- NumColumns = 12;
- Column0 = FullName();
- Column0Name = "Ticker name";
- Column1 = " ";
- Column1Name =" ";
- Column2 = ElderLong;
- Column2Name = "Long";
- Column3 = ElderLong AND EMA(C,130) > Ref(EMA(C,130),-5);
- Column3Name = "Long EMA Weekly Direction";
- Column4 = Column3 AND (bearpower < 0 AND bullpower > 0);
- Column4Name = "Long Elder Ray Filter";
- Column5 = " ";
- Column5Name =" ";
- Column6 = ElderShort;
- Column6Name = "Short";
- Column7 = ElderShort AND EMA(C,130) < Ref(EMA(C,130),-5);
- Column7Name = "Short EMA Weekly Direction";
- Column8 = Column7 AND (bearpower < 0 AND bullpower > 0);
- Column8Name = "Short Elder Ray Filter";
- Column9 = " ";
- Column9Name =" ";
- Column10 = TenTwentyFilter;
- Column10Name = "One Month Point Range";
- Column11 = FiftyDayHVFilter;
- Column11Name = "Historical Volotility 50 Day";
- AddTextColumn( IndustryID(1), "Industry" );
- AddTextColumn( MarketID(1), "Market" );
- // Filters
- Filter = VFilter AND (ElderLong OR ElderShort);
- Buy = ElderLong;
- Sell = 0;
- Short = ElderShort;
- Cover = 0;
- // ----------------------------------------------------------------------------------------------------------------------
- // Charts -- (cut and paste the chart/indicator to it's own window with it's own file name and remove the Remark Slashes "//", except
- // for the first line, this line desctibes the chart function. Example...leave "//Weekly Bar Chart" from the following first line as as.
- // Weekly Bar Chart
- //_SECTION_BEGIN("Weekly Graph");
- //TimeFrameSet( inWeekly );
- //wo = O;
- //wh = H;
- //wl = L;
- //wc = C;
- //TimeFrameRestore();
- //PlotOHLC( wo, wh, wl, wc, "Weekly Close", colorCustom9, styleBar );
- //_SECTION_END();
- //_SECTION_BEGIN("EMA");
- //P = ParamField("Price field",-1);
- //Periods = Param("Periods", 15, 2, 200, 1, 10 );
- //Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorYellow ), ParamStyle("Style") );
- //_SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Weekly Force Index 13 Chart
- //_SECTION_BEGIN("Weekly Force Index Thirteen Period");
- //TimeFrameSet( inWeekly );
- //FI=EMA(V*(C-Ref(C,-1)),13);
- //TimeFrameRestore();
- //Plot(FI,"FI",colorCustom11,styleLine);
- //Plot(0,"ZERO LINE",colorWhite,styleThick);
- //_SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Weekly MACD Histogran
- //_SECTION_BEGIN("Weekly MACD");
- //TimeFrameSet( inWeekly );
- //MACDw = MACD( 12, 26 ) - Signal( 12, 26, 9 );
- //MACDwLINE = MACD( 12, 26 ) ;
- //MACDwSignal = Signal( 12, 26, 9 );
- //TimeFrameRestore();
- //Plot(MACDw,"MACD Weekly",colorYellow,styleHistogram);
- //Plot(MACDwLINE,"MACD Weekly Line",colorRed,styleLine);
- //Plot(MACDwSignal,"MACD Weekly Signal Line",colorBlue,styleLine);
- //_SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Daily Bar Chart
- //_SECTION_BEGIN("Elder Daily Chart with Envelope");
- //SetChartOptions(0,chartShowArrows|chartShowDates);
- //Plot( EMA(C,13),"EMA(13)",colorRed,styleLine);
- //PlotForeign(GetBaseIndex(),IndustryID(1),colorWhite,styleLine|styleLeftAxisScale);
- // LookBkPd = 100 ;
- // AvgPd = 22 ;
- // ExternalBarPct = 15 ;
- // ConvergePct = 2 ;
- // Middle = EMA( C,AvgPd ) ;
- // Rng = HHV( H,LookBkPd ) - LLV( L,LookBkPd ) ;
- // X = Rng ;
- // deltaX = X/2 ;
- // do
- // {
- // Over = H > Middle + X ;
- // Under = L < Middle - X ;
- // OuterPct = 100*( Sum( Over, LookBkPd ) + Sum( Under, LookBkPd )
- // )/LookBkPd ;
- // OP = LastValue(OuterPct) ;
- // X=X+sign( OP - ExternalBarPct )*deltaX ;
- // deltaX = deltaX/2 ;
- // }while ( abs( OP - ExternalBarPct ) > ConvergePct ) ;
- // Plot( Middle, "MA", colorYellow, styleLine|styleNoTitle ) ;
- // Plot( Middle+X, "MA", colorSkyblue, styleDashed|styleNoTitle ) ;
- // Plot( Middle-X, "MA", colorSkyblue, styleDashed|styleNoTitle ) ;
- //_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
- //Plot( C, "Close", ParamColor("Color", colorCustom9 ), styleBar | ParamStyle("Style") | GetPriceStyle() );
- //_SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Daily Force Index 2 Period
- //_SECTION_BEGIN("Force Index 2 Day");
- //FI=EMA(V*(C-Ref(C,-1)),2);
- //Plot(FI,"FI",colorCustom11,styleLine);
- //Plot(0,"ZERO LINE",colorWhite,styleThick);
- //_SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Daily MACD Histogram
- //_SECTION_BEGIN("MACD");
- //r1 = Param( "Fast avg", 12, 2, 200, 1 );
- //r2 = Param( "Slow avg", 26, 2, 200, 1 );
- //r3 = Param( "Signal avg", 9, 2, 200, 1 );
- //Plot( ml = MACD(r1, r2), StrFormat(_SECTION_NAME()+"(%g,%g)", r1, r2), ParamColor("MACD color", colorRed ), ParamStyle("MACD style") );
- //Plot( sl = Signal(r1,r2,r3), "Signal" + _PARAM_VALUES(), ParamColor("Signal color", colorBlue ), ParamStyle("Signal style") );
- //Plot( ml-sl, "MACD Histogram", ParamColor("Histogram color", colorBlack ), styleNoTitle | ParamStyle("Histogram style", styleHistogram | styleNoLabel, maskHistogram ) );
- //_SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Daily BullPower
- //_SECTION_BEGIN("Bull Power EMA");
- ///*Bull Power*/
- //Lookback = Param ("EMA Lookback",13);
- //BullPower = High - EMA(Close,Lookback);
- //Plot (BullPower, "", ParamColor ("Color", colorCustom11), styleHistogram );
- //Title = Name() + " " + Date() + " Bull Power" + WriteVal (Lookback, 3.0) + " Day: " + WriteVal (BullPower, 5.3);
- //GraphXSpace = 5;
- //_SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Daily BearPower
- //_SECTION_BEGIN("Bear Power EMA");
- ///*Bear Power*/
- //Lookback = Param ("EMA Lookback", 13);
- //BearPower = Low - EMA(Close,Lookback);
- //Plot (BearPower, "", ParamColor ("Color", colorRed), styleHistogram );
- //Title = Name() + " " + Date() + " Bear Power" + WriteVal (Lookback, 3.0) + " Day: " + WriteVal (BearPower, 5.3);
- //GraphXSpace = 5;
- //_SECTION_END();
- // End ---------------------------------------------------------------------------------------------------------------------