DALEÙ!! PROFIT LOCKING & RELATIVE PRICE CHANNEL (PL_RPC) ! Author: Leon Wilson, TASC Jan 2008 ! Coded by: Richard Denning 11/09/2007 !INPUTS: !****************SET MODE FIRST************************ ! To use trailing stop & profit target, for trading and/or ! backtesting, you must set mode to '1'. To use for ! plotting on a chart, mode must be '2' and date of trade ! entry must be set. Chart of indicators will only work ! for the date entered and after: MODE is 1. ! 1 = backtest, 2 = charting define MO 9. ! month of trade entry define DA 25. ! day of trade entry define YEAR 2007. ! year of trade entry !************************************************************** BEAR_L is 21. ! Authors suggested setting MULT is 3.8. ! Authors suggested setting STOP_I is 3.0. ! Initial stop in ATRs (not in article) WILD is 34. ! Authors suggested setting OB_R is 70. ! Authors suggested setting ! CODING ABBREVIATIONS: H is [high]. L is [low]. L1 is val([low],1). C is [close]. C1 is val([close],1). O is [open]. PD is {position days}. PEP is {position entry price}. !AVERAGE TRUE RANGE: TR is Max(H - L,max(abs(C1 - L),abs(C1- H))). ATR is expAvg(TR,60). ! WILDER RSI: !Wilder Averaging to Exponential Averaging: !ExponentialPeriods = 2 * WilderPeriod - 1. U is C - C1. D is C1 - C. Len1 is 2 * WILD - 1. AvgU is ExpAvg(iff(U>0,U,0),Len1). AvgD is ExpAvg(iff(D>=0,D,0),Len1). rsi is 100-(100/(1+(AvgU/AvgD))). ! FUNCTIONS FOR PL_RPC: OB is expAvg(rsi - OB_R,1). Bullish is C - (C*(OB/100)). Bearish is simpleAvg(abs(C - L1),BEAR_L). RangeA is simpleAvg(C - L,BEAR_L). Stop is C - (Bearish + RangeA) * MULT. HoldD is iff(MODE = 1, PD,reportDate() - makeDate(MO,DA,YEAR)) . EntryP is iff(MODE = 1, PEP, valresult(O,HoldD)). StopInit is iff(MODE=1,PEP - STOP_I * valresult(ATR,HoldD), EntryP - STOP_I * valresult(ATR,HoldD)). ! ADD THE FOLLOWING TWO INDICATORS TO CHARTS AS ! AS SEPARATE SINGLE LINES TO DISPLAY ON PRICE CHART: StopTrl is iff(HoldD > 1,highresult(max(StopInit,Stop),HoldD),StopInit). BullZone is iff(Bullish >= StopTrl,Bullish,StopTrl). ! CHANNEL BREAKOUT LONG ONLY ENTRY RULE TO TEST ! PROFIT LOCKING & TRAILING STOP: LE if countof(C > highresult(H,34,1),5)>=1 and rsi <= OB_R - 10 . LX if (C1 > valresult(BullZone,1) and C < BullZone) or C < valresult(StopTrl,1). ! Same entry rule, pared with bear trailing stop (not using the profit locking) LE_TS if countof(C > highresult(H,34,1),5)>=1 and rsi <= OB_R - 10 . LX_TS if C < valresult(StopTrl,1). !--------------------------------TASC end here___________________________ ! SIGNAL RANKING INDICATORS: !AIQ LONG TERM RELATIVE STRENGTH !Coded by Rich Denning on 12/14/00 !Parameters supplied by AIQ for weights were 40%, 20%, 20%, 20%. 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). GRS_AIQLT is TickerUDF(RSticker(),RS_AIQLT). GRS_AIQLT1 is valresult(GRS_AIQLT,1). OTC_AIQLT is TickerUDF("OTC",RS_AIQLT). RS_AIQLTx5 is valresult(RS_AIQLT,5). Change2 is RS_AIQLT - RS_AIQLTx5. !AIQ MID TERM RELATIVE STRENGTH !Coded by Rich Denning on 12/14/00 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). GRS_AIQmt is TickerUDF(RSticker(),RS_AIQmt). GRS_AIQmt1 is valresult(GRS_AIQmt,1). OTC_AIQmt is TickerUDF("OTC",RS_AIQmt). !AIQ VERY SHORT TERM RELATIVE STRENGTH !Coded by Rich Denning on 12/14/00 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). GRS_AIQst is TickerUDF(RSticker(),RS_AIQst). GRS_AIQst1 is valresult(GRS_AIQst,1). OTC_AIQst is TickerUDF("OTC",RS_AIQst). RANK is 6*RS_AIQLT/sqrt(240) + 5*RS_AIQmt/sqrt(120) + 1*RS_AIQst/sqrt(32). LE_TS2 if countof(C > highresult(H,34,1),5)>=1 and rsi <= OB_R - 10 and rsi > 50 . LX_TS2 if C < valresult(StopTrl,1). LE_TS3 if countof(C > highresult(H,34,1),5)>=1 and rsi <= OB_R - 10 and TickerRule("NDX",rsi > 50) . LX_TS3 if C < valresult(StopTrl,1) or TickerRule("NDX",rsi < 45) . LE_TS4 if countof(C > highresult(H,34,1),5)>=1 and rsi > 55 and TickerRule("NDX",rsi > 55) . LX_TS4 if C < valresult(StopTrl,1) or TickerRule("NDX",rsi < 50) . Rule Libraryÿÿ CCodeViewLEÿÿ CReportViewÐSymbolÀ<LE_TS€ÐSymbolÀ<Xnas100ÿÿÿÿÿÿ CBackTestPropertyLELX2PPPe0Profit Lock LESPXPnas100 UUUUu<ã@H<ã@ÿÿÿÿ€…â@`<ã@€LE_TSLX_TS2PPPe0Profit Lock LE_TSSPXZnas100 UUUUu<ã@H<ã@ÿÿÿÿ€…â@`<ã@00:00