DALEå! THE PIVOT DETECTOR OSCILLATOR ! Author: Giorgos E. Silgardos, TASC July 2009 (Aug 2009 Traders' Tips) ! Coded by: Richard Denning 7/10/09 ! ABBREVIATIONS: C is [close]. C1 is valresult(C,1). sma200 is simpleavg(C,200). sma50 is simpleavg(C,50). sma20 is simpleavg(C,20). PD is {position days}. PEP is {position entry price}. HD if hasdatafor(220)>=200. ! PID INDICATOR: PIDrsi is iff(C>sma200,(rsi14-35)/50,(rsi14-20)/50)*100. ! PLOT overBot is iff(C>sma200,85,70). ! PLOT overSld is iff(C>sma200,35,20). ! PLOT ! SYSTEM TO TEST INDICATOR (AUTHOR'S VERSION): Buy if HD and PIDrsi > overSld and valrule(PIDrsi < overSld,1). Sell if HD and PIDrsi < overBot and valrule(PIDrsi > overBot,1). ! TREND FILTERED SYSTEM TO TEST INDICATOR: MktTmLong if tickerRule("SPX",C > sma200) and tickerRule("SPX",sma200 > valresult(sma200,1)). MktTmShort if tickerRule("SPX",C < sma200) and tickerRule("SPX",sma200 < valresult(sma200,1)). Buy2 if HD and MktTmLong and C > sma200 and sma200 > valresult(sma200,1) and PIDrsi > overSld and valrule(PIDrsi < overSld,1). MaxBars is 80. ExitLongTmMkt if MktTmShort or C < sma200 or Sell or PD > maxBars. !! RSI WILDER ! To convert Wilder Averaging to Exponential Averaging use this formula: ! ExponentialPeriods = 2 * WilderPeriod - 1. U is C - C1. D is C1 - C. W1 is 3. rsiLen1 is 2 * W1 - 1. AvgU is ExpAvg(iff(U>0,U,0),rsiLen1). AvgD is ExpAvg(iff(D>=0,D,0),rsiLen1). rsi3 is 100-(100/(1+(AvgU/AvgD))). W2 is 14. rsiLen2 is 2 * W2 - 1. AvgU2 is ExpAvg(iff(U>0,U,0),rsiLen2). AvgD2 is ExpAvg(iff(D>=0,D,0),rsiLen2). rsi14 is 100-(100/(1+(AvgU2/AvgD2))). ! RANKING UDFs FOR SIMULATION ON PORTFOLIO MANAGER: ! AIQ LONG TERM RELATIVE STRENGTH W is 1. ! Weekly mode = 5, daily mode = 1 LTL is 240/W. Q3 is LTL/4. Q2 is (LTL - Q3) / 3. Q1 is (LTL - Q2 - Q3) / 2. Q0 is LTL - Q1 - Q2 - Q3. Price1 is [close]. Price2 is [close]. ROCq3LT is (valresult(Price1,Q2,(Q1+Q0)) / valresult(Price2,Q3,(Q2+Q1+Q0)) - 1) * 100. ROCq2LT is (valresult(Price1,Q1,Q0) / valresult(Price2,Q2,(Q1+Q0)) - 1) * 100. ROCq1LT is (valresult(Price1,Q0,0) / valresult(Price2,Q1,Q0) - 1) * 100. ROCq0LT is (Price1 / valresult(Price2,Q0,0) - 1) * 100. RS_AIQLT is ROCq0LT * 0.40 + ROCq1LT * 0.20 + ROCq2LT * 0.20 + ROCq3LT * 0.20. RS_AIQLT1 is valresult(RS_AIQLT,1). ! AIQ MID TERM RELATIVE STRENGTH MTL is 120/W. Q3m is MTL / 4. Q2m is (MTL - Q3m) / 3. Q1m is (MTL - Q2m - Q3m) / 2. Q0m is MTL - Q1m - Q2m - Q3m. ROCq3m is (valresult(price1,Q2m,(Q1m+Q0m)) / valresult(price2,Q3m,(Q2m+Q1m+Q0m)) - 1) * 100. ROCq2m is (valresult(price1,Q1m,Q0m) / valresult(price2,Q2m,(Q1m+Q0m)) - 1) * 100. ROCq1m is (valresult(price1,Q0m,0) / valresult(price2,Q1m,Q0m) -1 ) * 100. ROCq0m is (price1 / valresult(price2,Q0m,0) - 1) * 100. RS_AIQmt is ROCq0m * 0.40 + ROCq1m * 0.20 + ROCq2m * 0.20 + ROCq3m * 0.20. RS_AIQmt1 is valresult(RS_AIQmt,1). ! AIQ SHORT TERM RELATIVE STRENGTH STL is 32/W. Q3s is STL / 4. Q2s is (STL - Q3s) / 3. Q1s is (STL - Q2s - Q3s) / 2. Q0s is STL - Q1s - Q2s - Q3s. ROCq3s is (valresult(price1,Q2s,(Q1s+Q0s)) / valresult(price2,Q3s,(Q2s+Q1s+Q0s)) - 1) * 100. ROCq2s is (valresult(price1,Q1s,Q0s) / valresult(price2,Q2s,(Q1s+Q0s)) - 1) * 100. ROCq1s is (valresult(price1,Q0s,0) / valresult(price2,Q1s,Q0s) - 1)* 100. ROCq0s is (price1 / valresult(price2,Q0s,0) - 1) * 100. RS_AIQst is ROCq0s * 0.40 + ROCq1s * 0.20 + ROCq2s * 0.20 + ROCq3s * 0.20. RS_AIQst1 is valresult(RS_AIQst,1). ! OTHER RULES AND EXITS TRIED BUT NOT USED IN ARTICLE: Buy1 if HD and MktTmLong and C > sma200 and PIDrsi > overSld and valrule(PIDrsi < overSld,1). Buy3 if HD and MktTmLong and C > sma200 and sma200 > valresult(sma200,1) and PIDrsi < overSld and rsi3 < 15 and rsi3 > valresult(rsi3,1) and C * simpleavg([volume],50) >= 50000. ExitLong if Sell or PD > maxBars. ExitLongMkt if tickerRule("SPX",C < sma200) or C < sma200 or Sell or PD > maxBars. ExitLongTmMkt2 if MktTmShort or C < sma200 or Sell or PD > maxBars or (PD >= 4 and C < PEP*(1-0.02)) or C > PEP*(1.10) or rsi3 > 90. Sell1 if HD and MktTmShort and C < sma200 and PIDrsi < overBot and valrule(PIDrsi > overBot,1). Sell2 if HD and MktTmShort and C < sma200 and sma200 < valresult(sma200,1) and PIDrsi < overBot and valrule(PIDrsi > overBot,1) and C * simpleavg([volume],50) >= 100000. Sell3 if HD and MktTmShort and C < sma200 and sma200 < valresult(sma200,1) and PIDrsi > overBot and rsi3 > 90 and rsi3 < valresult(rsi3,1) and C * simpleavg([volume],50) >= 50000. ExitShort if Buy or PD > maxBars. ExitShortMkt if tickerRule("SPX",C > sma200) or C > sma200 or Buy or PD > maxBars. ExitShortTmMkt if MktTmLong or C > sma200 or Buy or PD > maxBars. ExitShortTmMkt2 if MktTmLong or C > sma200 or Buy or PD > maxBars or (PD >= 4 and C > PEP*1.02) or C < PEP*(1-0.05) or rsi3 < 15. Rule Libraryÿÿ CCodeViewBuyÿÿ CReportViewÐSymbolÀ<Sell€ÐSymbolÀ<Buy1€ÐSymbolÀ<Sell1€ÐSymbolÀ<Buy2€ÐSymbolÀ<Sell2€ÐSymbolÀ<Buy3€ÐSymbolÀ<Sell3€ÐSymbolÀ<RUS1000Nÿÿÿÿÿÿ CBackTestPropertyBuySellPPŽ Pivot Osc BuySPXPCCRUS1000N ˜ˆã@hˆã@ÿÿÿÿ@Ýá@€ˆã@€SellBuyPPŽPivot Osc SellSPXPCCRUS1000N ˜ˆã@hˆã@ÿÿÿÿ@Ýá@€ˆã@€Buy3ExitLongTmMkt2PPÚPivot Osc Buy3SPXPCCRUS1000N øˆã@Ȉã@ÿÿÿÿ@7á@àˆã@€Buy2 ExitLongTmMktPPÚPivot Osc Buy2SPXPCCRUS1000N øˆã@Ȉã@ÿÿÿÿ@7á@àˆã@00:00