DALE! TRADING TRENDLINE BREAKS ! Using AIQ's new chart pattern service ! to test trendline breakouts ! Coded by: Paul Denning 4/4/2007 ! Richard Denning 7/12/2007 ! breakUP of a down Channel (no shorts) chanDwn is [Channel Down] . chanBOlong if chanDwn > 0 . ! breakDOWN of an up Channel (no longs) lenChan is ChartPatternLength([Channel Up]). chanUp is [Channel Up]. chanBOshort if chanUp > 2 or chanUp < 0. ! Flag up and down FLAG is [Flag] . upFLAG if FLAG > 0 . dwnFLAG if FLAG < 0 . ! pennant up and down pennant is [Pennant]. upPennant if pennant > 0 . dwnPennant if pennant < 0 . ! ascending triangle (long) AT is [Ascending Triangle] . ascTri if AT > 0 . ! descending triangle breakdown (short) DT is [Descending Triangle] . descTri if DT < 0 . ! TRIANGLE long and short tri is [Triangle] . triLNG if tri > 0 . triSRT if tri < 0 . ! LONG FALLING wedges FW is [Falling Wedge] . fallWdg if FW > 0 . ! SHORT FALLING wedges fallWdgSRT if FW < 0 . ! SHORT RISING wedges RW is [Rising Wedge] . riseWdg if RW < 0 . ! LONG RISING wedges riseWdgLNG if RW > 0 . ! long on double bottom doubBot is [Double Bottom] . doubleBt if doubBot > 0 . ! short on double top doubTop is [Double Top] . doubleTp if doubTop < 0 . ! rectangle up and down rect is [Rectangle] . upRect if rect > 0 . dwnRect if rect < 0 . ! COMBINED PATTERNS FOR TESTING TRENDLINE BREAKS ALL_Long if chanBOlong or upFLAG or upPennant or ascTri or triLNG or fallWdg or riseWdgLNG or doubleBt or upRect. LX if {position days}=3. NDXrule1 if TickerRULE("NDX",[close] > simpleavg([close],30)). NDX_SPX is expavg(TickerUDF("NDX",[close]) / TickerUDF("SPX",[close]),3). rcNDXspx is (NDX_SPX / valresult(NDX_SPX,5) - 1) * 100. ALL_LongM4 if (chanBOlong or upFLAG or upPennant or ascTri or triLNG or fallWdg or riseWdgLNG or doubleBt or upRect) and (NDXrule1 or (NDXrule1=0 and rcNDXspx > 1)). ALL_Short if chanBOshort or dwnFLAG or dwnPennant or descTri or triSRT or fallWdgSRT or riseWdg or doubleTp or dwnRect. SX if {position days}=3. ALL_ShortM4 if (chanBOshort or dwnFLAG or dwnPennant or descTri or triSRT or fallWdgSRT or riseWdg or doubleTp or dwnRect) and (NDXrule1=0 or (NDXrule1 and rcNDXspx < -1)). !AIQ RELATIVE STRENGTH (for signal ranking) STL is 32. Q3s is STL / 4. Q2s is (STL - Q3s) / 3. Q1s is (STL - Q2s - Q3s) / 2. Q0s is STL - Q1s - Q2s - Q3s. ROCq3s is (val([close],Q2s,(Q1s+Q0s)) - val([open],Q3s,(Q2s+Q1s+Q0s))) / val([open],Q3s,(Q2s+Q1s+Q0s)) * 100. ROCq2s is (val([close],Q1s,Q0s) - val([open],Q2s,(Q1s+Q0s))) / val([open],Q2s,(Q1s+Q0s)) * 100. ROCq1s is (val([close],Q0s,0) - val([open],Q1s,Q0s)) / val([open],Q1s,Q0s) * 100. ROCq0s is ([close] - val([open],Q0s,0)) / val([open],Q0s,0) * 100. RS_AIQst is ROCq0s * 0.40 + ROCq1s * 0.20 + ROCq2s * 0.20 + ROCq3s * 0.20. !--------------NOT USED FOR TASC------------------------------------------------- ! breakout of INVERTED Head and Shoulders up (NOTE: for shorts, use normal head and shoulders) ! CAN'T GET THIS TO WORK invrtHS is [Inv Head and Shoulders] . uHSBO if invrtHS < 0 . ! breakout of Head and Shoulders down (NOTE: for longs, use INVERTED head and shoulders) HS is [Head and Shoulders]. dHSBO if HS < 0. ! triple bottom LONG triBot is [Triple Bottom] . tripBt if triBot > 0 . ! triple top SHORT triTop is [Triple Top] . tripTp if triTop < 0 . ALL_LongM1 if (chanBOlong or upFLAG or upPennant or ascTri or triLNG or fallWdg or riseWdgLNG or doubleBt or upRect) and NDXrule1. LX1 if NDXrule1=0. NDXrule2 if TickerRULE("NDX",[close] > simpleavg([close],20)). ALL_LongM2 if (chanBOlong or upFLAG or upPennant or ascTri or triLNG or fallWdg or riseWdgLNG or doubleBt or upRect) and NDXrule2. LX2 if NDXrule2=0. NDXrule3 if TickerRULE("NDX",[close] > simpleavg([close],10)). ALL_LongM3 if (chanBOlong or upFLAG or upPennant or ascTri or triLNG or fallWdg or riseWdgLNG or doubleBt or upRect) and NDXrule3. LX3 if NDXrule3=0. LX4 if (NDXrule1=0 and rcNDXspx < -1) or {position days}=3. SX4 if (NDXrule1 and rcNDXspx >1) or {position days}=3. ! ATstopLoss is {Position Entry Price} * 0.97 . ! ATstoppedOut if [Low] < ATstopLoss . ! ATprofitTarg is {Position Entry Price} * 1.06 . ! ATprofitExit if [High] > ATprofitTarg . ! ATexitprice is Iff(ATstoppedOut, Min([Open],ATstopLoss), Max([Open], ATprofitTarg)) . ! ATexit if ATprofitExit or ATstoppedOut . Rule Libraryÿÿ CCodeView ALL_LongM1ÿÿ CReportViewÐSymbolÀ< ALL_LongM4€ÐSymbolÀ< ALL_Short€ÐSymbolÀ< ALL_ShortM4€ÐSymbolÀ< chanBOlong€ÐSymbolÀ< chanBOshort€ÐSymbolÀ<upFLAG€ÐSymbolÀ<dwnFLAG€ÐSymbolÀ< uppennant€ÐSymbolÀ< dwnPennant€ÐSymbolÀ<ascTri€ÐSymbolÀ<descTri€ÐSymbolÀ<triLNG€ÐSymbolÀ<triSRT€ÐSymbolÀ<fallWdg€ÐSymbolÀ< fallWdgSRT€ÐSymbolÀ<riseWdg€ÐSymbolÀ< riseWdgLNG€ÐSymbolÀ<doubleBt€ÐSymbolÀ<doubleTp€ÐSymbolÀ<uHSBO€ÐSymbolÀ<dHSBO€ÐSymbolÀ<upRect€ÐSymbolÀ<dwnRect€ÐSymbolÀ<tripBt€ÐSymbolÀ<tripTp€ÐSymbolÀ<NAS100ÿÿÿÿÿÿ CBackTestProperty chanBOlong1PPž chanBOlong1dSPXPNAS100 ø ã@«ªªªÌ ã@ÿÿÿÿÀìâ@`-ã@€ chanBOshort!PPÃÈ chanBOshort1dSPXPsp1500 ø ã@«ªªªÌ ã@ÿÿÿÿ`óâ@!ã@€upFLAG1PPžupFLAG1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€dwnFLAG!PPÄÉ dwnFLAG1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€ uppennant1PPž upPennant1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€ dwnPennant!PPÄÉ dwnPennant1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€uHSBO1PPžuHSBO1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€dHSBO!PPÄÉ dHSBO1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€upRect1PPžupRect1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€dwnRect!PPÄÉ dwnRect1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€ascTri1PPžascTri1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€descTri!PPÄÉ descTri1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€doubleBt1PPž doubleBt1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€doubleTp!PPž doubleTp1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€fallWdg1PPž fallWdg1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€riseWdg!PPÄÉ riseWdg1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€ fallWdgSRT!PPÄÉ fallWdgSRT1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€ riseWdgLNG1PPž riseWdgLNG1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€triLNG1PPžtriLNG1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€triSRT!PPÄÉ triSRT1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€tripBt1PPžtripBt1dSPXPNAS100 !ã@«ªªªì ã@ÿÿÿÿÀìâ@`-ã@€tripTp!PPÄÉ tripTp1dSPXPsp1500 !ã@«ªªªì ã@ÿÿÿÿ€óâ@ !ã@€ALL_Long1PPž ALL_Long 3dSPXPNAS100 UUUUu-ã@H-ã@ÿÿÿÿÀìâ@`-ã@00:00