DALE»! ENTERING THE PRICE ZONE ! Authors: Walid Khalil and David Steckler TASC June 2011 ! Coded by: Richard Denning 4/16/11 ! www.TradersEdgeSystems.com ! INPUTS: pLen is 14. !INPUT IS USED FOR PZO vLen is 14. !INPUT IS USED FOR VZO wLen is 14. !INPUT USED FOR DMI, ATR, ADX, ADX RATE eLen is 60. !INPUT USED FOR EMA FOR TREND DETERMINATION oLen is 21. !INPUT USED FOR LOOKBACK FOR VZO OVERBOT/OVERSOLD usePZO is 1. !INPUT DETERMINES WHICH INDICATOR IS USED PZO=1 FOR PZO useVZO is iff(usePZO=1,0,1). !CODING ABREVIATIONS: H is [high]. L is [low]. C is [close]. C1 is valresult(C,1). H1 is valresult(H,1). L1 is valresult(L,1). V is [volume]. Pdays is {position days}. !PZO INDICATOR FORMULAS: CP is expavg(iff(C>C1,C,-C),pLen). TC is expavg(C,pLen). !PLOT PZO as custom indicator with +60 -60 support lines: PZO is CP / TC * 100. !VZO INDICATOR FORMULAS: R is iff(C > C1,V,-V). VP is expavg(R,vLen). TV is expavg(V,vLen). !PLOT VZO as custom indicator with +60 -60 support lines: VZO is (VP / TV) * 100. !DMI & ADX indicators as defined by Wells Wilder. ! NOTE: Wilder to expontential averaging the formula is: ! Wilder length * 2 -1 = exponential averaging length avgLen is wLen * 2 - 1. !AVERAGE TRUE RANGE: TR is Max(H-L,max(abs(C1-L),abs(C1-H))). ATR is expAvg(TR,avgLen). !+DM -DM CODE: rhigh is (H-H1). rlow is (L1-L). DMplus is iff(rhigh > 0 and rhigh > rlow, rhigh, 0). DMminus is iff(rlow > 0 and rlow >= rhigh, rlow, 0). AvgPlusDM is expAvg(DMplus,avgLen). AvgMinusDM is expavg(DMminus,avgLen). PlusDMI is (AvgPlusDM/ATR)*100. !PLOT AS INDICATOR MinusDMI is AvgMinusDM/ATR*100. !PLOT AS INDICATOR !ADX INDICATOR DIdiff is PlusDMI-MinusDMI. ZERO if PlusDMI = 0 and MinusDMI = 0. DIsum is PlusDMI+MinusDMI. DX is iff(ZERO,100,abs(DIdiff)/DIsum*100). !PLOT ADX as single line indicator with support at 24 is same as ADX (AIQ): ADX is ExpAvg(DX,avgLen). !TRADING SYSTEM RULES: EMA is expavg(C,eLen). ZO is iff(usePZO = 1,PZO,iff(useVZO = 1,VZO,[RSI Wilder])). UpTrend if ADX > 18 and C > EMA. ZObuy1 if ZO > -40 and valrule(ZO < -40,1). ZObuy2 if countof(ZO > 40,oLen) >=1 and ZO > 0 and valrule(ZO < 0,1). ZObuy3 if ZO > 15 and valrule(ZO < 15,1). Buy if UpTrend and (ZObuy1 or ZObuy2) and NOT Sell. BuyNoTrnd if ADX < 18 and (ZObuy1 or ZObuy3). ZOsell1 if countof(ZO > 60,2,1) >= 1 and ZO < valresult(VZO,1). ZOsell2 if slope2(C,vLen/2) > 0 and slope2(ZO,vLen/2) < 0 and ZO < 40. ZOsell3 if C < EMA and ZO < 0. ZOsell4 if countof(ZO > 40,Pdays) >=1 and (ZOsell1 or ZOsell2 or ZOsell3). ZOsell5 if countof(ZO > 40,Pdays) = 0 and ZO < -5 and valresult(ZO,1) > -5. Sell if ZOsell1 or ZOsell2 or ZOsell3. SellNoTrnd if ZOsell4 or ZOsell5. DnTrend if ADX > 18 and C < EMA. ZOshort1 if ZO < 40 and valrule(ZO > 40,1). ZOshort2 if countof(ZO < -40,oLen) >=1 and ZO < 0 and valrule(ZO > 0,1). ZOshort3 if ZO < -5 and valrule(ZO > -5,1). Short if DnTrend and (ZOshort1 or ZOshort2) and NOT Cover. ShortNoTrnd if ADX < 18 and (ZOshort1 or ZOshort3). ZOcover1 if countof(ZO < -60,2,1) >= 1 and ZO > valresult(VZO,1). ZOcover2 if slope2(C,vLen/2) < 0 and slope2(ZO,vLen/2) > 0 and ZO > -40. ZOcover3 if C > EMA and ZO > 0. ZOcover4 if countof(ZO < -40,Pdays) >=1 and (ZOcover1 or ZOcover2 or ZOcover3). ZOcover5 if countof(ZO < -40,Pdays) = 0 and ZO > 15 and valresult(ZO,1) < 15. Cover if ZOcover1 or ZOcover2 or ZOcover3. CoverNoTrnd if ZOcover4 or ZOcover5. !PLOT DivergInd to see when the divergence is occuring: DivergInd is iff(ZOsell2,-100, ! SELL EXIT DIVERGENCE = -100 iff(ZOcover2,100,0)). ! COVER EXIT DIVERGENCE = 100 !REVISED ENTRY RULES WITH MARKET TREND FILTERS: SPXema is TickerUDF("SPX",EMA). NDXema is TickerUDF("NDX",EMA). SPXadx is TickerUDF("SPX",ADX). NDXadx is TickerUDF("NDX",ADX). SMA is simpleavg(C,200). SPXsma is TickerUDF("SPX",SMA). NDXsma is TickerUDF("NDX",SMA). SPXc is TickerUDF("SPX",C). NDXc is TickerUDF("NDX",C). BuyMkt if Buy and SPXema > valresult(SPXema,10) and SPXc > SPXsma and SPXadx > 18. ShortMkt if Short and SPXema < valresult(SPXema,10). BuyMktNDX if Buy and NDXema > valresult(NDXema,10) and NDXc > NDXsma and NDXadx > 18. ShortMktNDX if Short and NDXema < valresult(NDXema,10) . BuyMktBoth if Buy and NDXema > valresult(NDXema,10) and SPXema > valresult(SPXema,10) and SPXadx > 18 and NDXadx > 18. ShortMktBoth if Short and NDXema < valresult(NDXema,10) and SPXema < valresult(SPXema,10). List if 1. Rule Libraryÿÿ CCodeViewBuyÿÿ CReportViewÐSymbolÀ< BuyNoTrnd€ÐSymbolÀ<BuyMkt€ÐSymbolÀ< BuyMktNDX€ÐSymbolÀ< BuyMktBoth€ÐSymbolÀ<Short€ÐSymbolÀ< ShortNoTrnd€ÐSymbolÀ<ShortMkt€ÐSymbolÀ< ShortMktNDX€ÐSymbolÀ< ShortMktBoth€ÐSymbolÀ<ßnas100ÿÿÿÿ ÿÿ CBackTestPropertyBuySellPPªßEnterPriceZone BuySPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿ@âá@ Øã@€BuyMktSellPPªßEnterPriceZone BuyMktSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿ@âá@ Øã@€ BuyMktNDXSellPPªßEnterPriceZone BuyMktNDXSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿ@âá@ Øã@€ShortCoverPP&0EnterPriceZone ShortSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿÀ÷á@@Sâ@€ShortMktCoverPP&0EnterPriceZone ShortMktSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿÀ÷á@@Sâ@€ ShortMktNDXCoverPPªßEnterPriceZone ShortMktNDXSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿ@âá@ Øã@€ BuyMktBothSellPPªßEnterPriceZone BuyMktBothSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿ@âá@ Øã@€ ShortMktBothCoverPPªßEnterPriceZone ShortMktBothSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿ@âá@ Øã@€ BuyNoTrnd SellNoTrndPPªßEnterPriceZone BuyNoTrndSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿ@âá@ Øã@€ ShortNoTrnd CoverNoTrndPPªßEnterPriceZone ShortNoTrndSPXPnas100 «ªªª6Øã@«ªªªØã@ÿÿÿÿ@âá@ Øã@00:00