Elder Triple Screen Trading System (499).afl
上传用户:shiqiang
上传日期:2009-06-12
资源大小:1289k
文件大小:10k
源码类别:
金融证券系统
开发平台:
Others
- //------------------------------------------------------------------------------
- //
- // Formula Name: Elder Triple Screen Trading System
- // Author/Uploader: Dennis Skoblar
- // E-mail: DennisAndLisa@sbcglobal.net
- // Date/Time Added: 2005-07-10 14:17:44
- // Origin: Derrived from the trading books, "Trading For A Living" and "Come Into My Trading Room" by Alexander Elder.
- // Keywords: Triple Screen, Alexander Elder,Pullback scan
- // Level: semi-advanced
- // Flags: system,exploration
- // Formula URL: http://www.amibroker.com/library/formula.php?id=499
- // Details URL: http://www.amibroker.com/library/detail.php?id=499
- //
- //------------------------------------------------------------------------------
- //
- // 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 display the Weekly EMA only 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 display the Weekly EMA only 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(((C-Ref(C,-1))*V),13);
- WeeklyForceIndexLong = FIWeekly > 0;
- WeeklyForceIndexShort = FIWeekly < 0;
- TimeFrameRestore();
- // Weekly criteria
- MACDLongW = TimeFrameExpand( WeekHistRising, inDaily );
- MACDShortW= TimeFrameExpand( WeekHistFalling, inDaily );
- FILongW = TimeFrameExpand( WeeklyForceIndexLong, inDaily );
- FIShortW = TimeFrameExpand( WeeklyForceIndexShort, inDaily );
- // Daily criteria
- FIDaily = EMA(((C-Ref(C,-1))*V),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)
- bullpower= High - EMA(Close,13);
- bearpower= Low - EMA(Close,13);
- // Scan criteria
- ElderLong = MACDLongW AND FILongD;
- ElderShort = MACDShortW AND FIShortD;
- // Columns for exploration
- NumColumns = 11;
- 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 = ElderLong 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 = ElderShort AND (bearpower < 0 AND bullpower > 0);
- Column8Name = "Short Elder Ray Filter";
- Column9 = " ";
- Column9Name =" ";
- Column10 = TenTwentyFilter;
- Column10Name = "One Month Point Range";
- AddTextColumn( IndustryID(1), "Industry" );
- AddTextColumn( MarketID(1), "Market" );
- // Filters
- Filter = TenTwentyFilter > 5 AND VFilter AND (ElderLong OR ElderShort);
- Buy = ElderLong;
- Sell = ElderShort;
- // Charts (just cut and paste each to it's owm window)-------------------------------------------------------------------
- // 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", colorCycle ), ParamStyle("Style") );
- _SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Weekly Force Index 13 Chart
- _SECTION_BEGIN("Weekly Force Index Thirteen Period");
- TimeFrameSet( inWeekly );
- FI=EMA(((C-Ref(C,-1))*V),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("Price");
- SetChartOptions(0,chartShowArrows|chartShowDates);
- _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();
- _SECTION_BEGIN("EMA");
- P = ParamField("Price field",-1);
- Periods = Param("Periods", 13);
- Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorYellow ), ParamStyle("Style") );
- _SECTION_END();
- _SECTION_BEGIN("EMA1");
- P = ParamField("Price field",-1);
- Periods = Param("Periods", 22);
- Plot( EMA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorRed ), ParamStyle("Style") );
- _SECTION_END();
- // ----------------------------------------------------------------------------------------------------------------------
- // Daily Force Index 2 Period
- _SECTION_BEGIN("Force Index 2 Day");
- FI=EMA(((C-Ref(C,-1))*V),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 ---------------------------------------------------------------------------------------------------------------------