#Tom Demark's TD Combo - Frankensteind #hint offset: Length of ATR used to offset arrows from price.

input ATRLength = 15; #hint ATRScale: multiplier of offset. input ATRScale = 0.3; #hint showrisklevels: Displays TDRiskLevels for countdowns. input showrisklevels = {default "Yes", "No"}; #hint ComboType: Traditional uses default price comparisions, utilizing closing values, to predict price exhaustion. Aggressive is much more liberal and utiliz es price high values in computationof price exhaustion points. Aggressive setti ngs will provide more trading oppotunities with slightly increased risk. input ComboType = {default "Traditional", "Aggressive"}; #hint CountDownType: Type I requires the same elements for each count, 1-13. T ype II replicates Type I for counts 1-10. However, there is only one requiremen t, a higher/lower close for ounts 11-13. Type II provides the trader with more live opportunities with the tradeoff being a slight increase to risk. TD Termin ation is the same as Type I through Count 12, with count 13 qualifying using Ope n instead of close within the price comparisions. input CountDownType = {default "One", "Two", "TDTermination"}; #hint ShowFirst: Display initial counts subsequent with setup counts 1 through 9. input ShowFirst = {default "No", "Yes"}; #hint ShowSubCounts: Will display a developing Combo Countdown sequence in the event of a setup in the same direction as the initial countdown. input ShowSubCounts = {default "No", "Yes"}; #hint TDBullishflip: show TD Bullish Flip. input TDBullishFlip = {default "Yes", "No"}; #hint TDBearishFlip: show TD Bearish Flip. input TDBearishFlip = {default "Yes", "No"}; #hint BuyperfectionON: Show Perfection of TD Buy Setup. input BuyperfectionON = {default "Yes", "No"}; #hint SellperfectionON: Show Perfection of TD Sell Setup. input SellperfectionON = {default "Yes", "No"}; #hint riskbars: The integer selected equates to the number of bars TDRiskLevels are plotted into the future. input riskbars = 20; input showlabel = yes; def ATR = AvgTrueRange(high, close, low, 20); def Offset = ATRScale * ExpAverage(TrueRange(high, close, low), ATRLength); input setupPrice = close; def B = Floor( fold j = 0 to 10 with iX = 0 do if GetValue(SetupPrice, 9 - j, 20 ) < GetValue(SetupPrice, 13 - j, 20) then iX + 1 else 0 ); def CounterA = fold k = 1 to 10 with iCounter = 0 do if B == k and (fold l = 1 t o 10 - k with iCheck = 1 do iCheck * (if GetValue(B, -l, 20) == k + l or IsNaN(G etValue(SetupPrice, -l, 20)) then 1 else 0)) then k else iCounter; plot TDBuySetup = if !CounterA then Double.NaN else CounterA; TDBuySetup.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW); TDBuySetup.SetDefaultColor(CreateColor(4, 245, 4)); def S = Floor( fold N = 0 to 10 with MX = 0 do if GetValue(SetupPrice, 9 - N, 20 ) > GetValue(SetupPrice, 13 - N, 20) then MX + 1 else 0 ); def CounterB = fold O = 1 to 10 with MCounter = 0 do if S == O and (fold P = 1 t o 10 - O with MCheck = 1 do MCheck * (if GetValue(S, -P, 20) == O + P or IsNaN(G etValue(SetupPrice, -P, 20)) then 1 else 0)) then O else MCounter; plot TDSellSetup = if !CounterB then Double.NaN else CounterB;

184)).TDSellSetup. TDSellSetup. def Counter = B.SetDefaultColor(CreateColor(172. 255)). rec TDSTResistance = if CounterA == 1 then truehigh else if CounterA == 2 && truehigh > TDSTResistance[1] then truehigh else if CounterA == 3 && truehigh > T DSTResistance[1] then truehigh else if TDSTResistance[1] > 1 && TrueLow > TDSTRe sistance[1] then 0 else TDSTResistance[1]. Colo r.SetDefaultColor(CreateColor(0. C olor.GREEN). 8. rec direction = if Counter == 9 then 1 else if CounterXX == 9 then -1 else direc tion[1]. def LL = Lowest(TrueLow. close[1]).VALUES_ABOVE). TDSTSupportX.DASHES). 170.SetPaintingStrategy(PaintingStrategy. rec SellSetupCt = if IsNaN(SellSetupCt[1]) then 0 else if truehigh < TDSTSuppor t[1] && TDSTSupport[1] > 0 then 0 else if CounterXX == 9 && CounterXX[1] < 9 && SellSetupCt[1] < 1 then 1 else if CounterXX == 9 && CounterXX[1] < 9 && SellSe tupCt[1] >= 1 then SellSetupCt[1] + 1 else if Counter == 9 && Counter[1] < 9 t hen 0 else SellSetupCt[1]. rec BuySetupCt = if IsNaN(BuySetupCt[1]) then 0 else if TrueLow > TDSTResistanc e[1] && TDSTResistance[1] > 0 then 0 else if Counter == 9 && Counter[1] < 9 && BuySetupCt[1] < 1 then 1 else if Counter == 9 && Counter[1] < 9 && BuySetupCt[1 ] >= 1 then BuySetupCt[1] + 1 else if CounterXX == 9 && CounterXX[1] < 9 then 0 else BuySetupCt[1]. AddLabel(if showlabel then yes else no. rec TDSTSupport = if CounterB == 1 then TrueLow else if CounterB == 2 && TrueLow < TDSTSupport[1] then TrueLow else if CounterB == 3 && TrueLow < TDSTSupport[1] then TrueLow else if TDSTSupport[1] > 1 && truehigh < TDSTSupport[1] then 0 el se TDSTSupport[1]. rec ExtBuySetupCt = if BuySetupCt > BuySetupCt[1] then 9 else if ExtBuySetupCt[1 ] >= 9 && close < close[4] then ExtBuySetupCt[1] + 1 else if ExtBuySetupCt[1] >= . def CounterXX = S. TDSTSupportX. TDSTResistanceX.NaN. rec TDSTRX = if Counter == 9 && Counter[1] < 9 then TDSTResistance else if Count erXX == 9 && CounterXX[1] < 9 then 0 else if Counter == 9 && TDSTRX[1] > 1 then TDSTResistance else TDSTRX[1].SetLineWeight(1).DASHES).RED).SetLineWeight(1). TDSTResistanceX.SetPaintingStrategy(PaintingStrategy. plot TDSTSupportX = if TDSTSupport > 0 then TDSTSupport else Double. 7. def TrueLow = Min(low. 9).SetDefaultColor(CreateColor(255. rec TDSTSX = if CounterXX == 9 && CounterXX[1] < 9 then TDSTSupport else if Cou nter == 9 && Counter[1] < 9 then 0 else if CounterXX == 9 && TDSTSX[1] > 1 then TDSTSupport else TDSTSX[1]. 0)).N aN. Counter). close[1]). AddLabel(if showlabel then yes else no. 9). plot TDSTResistanceX = if TDSTResistance > 0 then TDSTResistance else Double. CounterXX). TDSTSupportX. Concat("TDBuySetup = " .SetPaintingStrategy(PaintingStrategy. TDSTResistanceX. Concat("TDSellSetup = " . def truehigh = Max(high. def HH = Highest(truehigh.

switch (ComboType) { case Traditional: CountPrice = if AutomaticRecycle or (CounterA == 1 && BuySetupCt[1] < 1) th en 0 else if VCombo && CountPrice[1] < 1 then close else if VCombo && close < CountPrice[1] && CountPrice[1] > 1 then close else CountPrice[1]. rec prevTR = if getTR == 0 && getTR[1] != 0 then getTR[1] else prevTR[1]. rec PrevTLX = if getTLX == 0 && getTLX[1] != 0 then getTLX[1] else PrevTLX[1]. switch (ComboType) { case Traditional: V1 = close <= low[2]. def V1. rec PrevTL = if gettl == 0 && gettl[1] != 0 then gettl[1] else PrevTL[1]. VCombo = V1 && V2 && V3. rec ExtSellSetupCt = if SellSetupCt > SellSetupCt[1] then 9 else if ExtSellSetup Ct[1] >= 9 && close > close[4] then ExtSellSetupCt[1] + 1 else if ExtSellSetupCt [1] >= 26 then 0 else if close < close[4] then 0 else ExtSellSetupCt[1].28 then 0 else if close > close[4] then 0 else ExtBuySetupCt[1]. rec gettl = if ExtBuySetupCt == 9 then LL else if ExtBuySetupCt[1] >= 9 && TrueL ow < gettl[1] then TrueLow else if close > close[4] then 0 else gettl[1]. V3 = low <= low[1]. rec getTR = if BuySetupCt > BuySetupCt[1] then (getth . VCombo = V1 && V2 && V3.gettl) else if getTR[1] > 0 && ExtBuySetupCt > ExtBuySetupCt[1] && ExtBuySetupCt[1] >= 9 then (getth . rec PrevTHX = if getTHX == 0 && getTHX[1] != 0 then getTHX[1] else PrevTHX[1]. rec getTRX = if SellSetupCt > SellSetupCt[1] then (getTHX . def V3.getTLX) else if close < close[4] then 0 else getTRX[1]. } rec NewSetupPriceCount. rec getTLX = if ExtSellSetupCt == 9 then LL else if ExtSellSetupCt[1] >= 9 && Tr ueLow < getTLX[1] then TrueLow else if close < close[4] then 0 else getTLX[1]. rec getTHX = if ExtSellSetupCt == 9 then HH else if ExtSellSetupCt[1] >= 9 && tr uehigh > getTHX[1] then truehigh else if close < close[4] then 0 else getTHX[1].g ettl) else if close > close[4] then 0 else getTR[1]. case Aggressive: V1 = low <= low[2]. V3 = close < close[1]. def AutomaticRecycle = (S == 9 && S[1] != 9) or (TrueLow > TDSTResistance[1] && TDSTResistance[1] != 0 ). rec PrevTH = if getth == 0 && getth[1] != 0 then getth[1] else PrevTH[1]. } rec getth = if ExtBuySetupCt == 9 then HH else if ExtBuySetupCt[1] >= 9 && trueh igh > getth[1] then truehigh else if close > close[4] then 0 else getth[1]. . def V2.getTLX) else if getT RX[1] > 0 && ExtSellSetupCt > ExtSellSetupCt[1] && ExtSellSetupCt[1] >= 9 then ( getTHX . def VCombo. rec prevTRX = if getTRX == 0 && getTRX[1] != 0 then getTRX[1] else prevTRX[1]. V2 = low <= low[1]. V2 = low <= low[1]. case Aggressive: CountPrice = if AutomaticRecycle or (CounterA == 1 && BuySetupCt[1] < 1) th en 0 else if VCombo && CountPrice[1] < 1 then low else if VCombo && low < Coun tPrice[1] && CountPrice[1] > 1 then low else CountPrice[1]. rec CountPrice.

rec recyclecheck = if B[1] < 8 then 0 else if B == 9 && B[1] != 9 && BuySetupCt[ 1] >= 1 && BuySetupCt != BuySetupCt[1] && getTR > prevTR && getTR < prevTR * 5 & & recyclecheck[1] < 1 then 1 else 0. def VComboAXX = VCombo && QualifyNewCountPrice. rec onetonineAX = if IsNaN(onetonineAX[1]) then 0 else if CounterA == 1 && VComb oAXX && BuySetupCt[1] >= 1 then 1 else if CounterA > 1 && CounterA[1] < 9 && VCo mboAXX && BuySetupCt[1] >= 1 then onetonineAX[1] + 1 else if B[1] == 9 then 0 el se onetonineAX[1]. } def QualifyNewCountPrice = CounterA >= 1 && CounterA <= 9 && NewSetupPriceCount != NewSetupPriceCount[1] && VCombo && BuySetupCt[1] >= 1. def VComboAX = VCombo && QualifyCountPrice. .618)) && VComboAX && BuySetupCt[1] >= 1 then ComboBuyCount[1] + 1 else if ComboBuyCount[1] > 0 && B = = 9 && B[1] != 9 && BuySetupCt > BuySetupCt[1] && (getTR < prevTR or getTR > (pr evTR * 1.switch (ComboType) { case Traditional: NewSetupPriceCount = if IsNaN(NewSetupPriceCount[1]) or AutomaticRecycle the n 0 else if NewSetupPriceCount[1] < 1 && CounterA == 1 && VCombo && BuySetupCt[1 ] >= 1 then close else if NewSetupPriceCount[1] < 1 && CounterA == 1 && BuySetup Ct[1] >= 1 && !VCombo then 1 else if CounterA > 1 && CounterA[1] < 9 && NewSetup PriceCount[1] == 1 && VCombo && BuySetupCt[1] >= 1 then close else if CounterA > 1 && CounterA <= 9 && NewSetupPriceCount[1] > 1 && close < NewSetupPriceCount[1 ] && BuySetupCt[1] >= 1 then close else if B[1] == 9 && BuySetupCt[1] >= 2 then 0 else NewSetupPriceCount[1]. rec onetonineA = if IsNaN(onetonineA[1]) then 0 else if CounterA == 1 && VComboA X then 1 else if CounterA > 1 && CounterA[1] < 9 && VComboAX then onetonineA[1 ] + 1 else if B[1] == 9 then 0 else onetonineA[1].618) && Counter == 9 && VComboAXX then onetonineAX[1] + 1 else if ComboBuyCount[1] > 0 && B == 9 && B[1] != 9 && BuySetupCt[1] >= 1 && BuySetupCt > BuySetupCt[1] && (getTR > prevTR && getTR < (prevTR * 1. rec ComboBuyCount = if IsNaN(ComboBuyCount[1]) or (ComboBuyCount[1] == 13 ) or A utomaticRecycle then 0 else if ComboBuyCount[1] < 1 && B == 9 && B[1] != 9 && V ComboAX then onetonineA[1] + 1 else if ComboBuyCount[1] < 1 && B == 9 && B[1] != 9 && !VComboAX then onetonineA[1] else if ComboBuyCount[1] > 0 && VComboAX && B != 9 then ComboBuyCount[1] + 1 else if ComboBuyCount[1] > 0 && B == 9 && B[1] != 9 && BuySetupCt[1] >= 1 && BuySetupCt > BuySetupCt[1] && (getTR > prevTR) && getTR < (prevTR * 1. case Aggressive: NewSetupPriceCount = if IsNaN(NewSetupPriceCount[1]) or AutomaticRecycle the n 0 else if NewSetupPriceCount[1] < 1 && CounterA == 1 && VCombo && BuySetupCt[1 ] >= 1 then low else if NewSetupPriceCount[1] < 1 && CounterA == 1 && BuySetupCt [1] >= 1 && !VCombo then 1 else if CounterA > 1 && CounterA[1] < 9 && NewSetupPr iceCount[1] == 1 && VCombo && BuySetupCt[1] >= 1 then low else if CounterA > 1 & & CounterA <= 9 && NewSetupPriceCount[1] > 1 && low < NewSetupPriceCount[1] && B uySetupCt[1] >= 1 then low else if B[1] == 9 && BuySetupCt[1] >= 2 then 0 else N ewSetupPriceCount[1].618)) && !VComboAX && BuySetupCt[1] >= 1 then ComboBuyCount[1] else Com boBuyCount[1].618)) && Counter == 9 && !VComboAX then o netonineAX[1] else if ComboBuyCount[1] > 0 && B == 9 && B[1] != 9 && BuySetupCt > BuySetupCt[1] && (getTR < prevTR or getTR > (prevTR * 1. def QualifyCountPrice = if VCombo && CountPrice[1] < 1 then 1 else if CountPr ice < CountPrice[1] && VCombo then 1 else if CounterA == 1 && BuySetupCt[1] < 1 then 1 else 0.

NaN. rec TDTerminationCountBuy = if AutomaticRecycle then 0 else if ComboBuyCount[1] < 12 && ComboBuyCount == 12 && TDTerminationCountBuy[1] < 1 then 1 else if TDTer minationCountBuy[1] == 1 && (open <= CountPrice[1] or close <= CountPrice[1]) th en 2 else if TDTerminationCountBuy[1] >= 2 then 0 else TDTerminationCountBuy[1].SetDefaultColor(CreateColor(0.SetPaintingStrategy(PaintingStrategy. BuyComboCountDown. . switch (CountDownType) { case "One": ComboBuyCountDown = if ComboBuyCount != ComboBuyCount[1] && ComboBuyCount[1] < 13 && ComboBuyCount > 0 then ComboBuyCount else ComboBuyCountDown[1]. #case "TDTerminationII": # ComboBuyCountDown = if ComboBuyCount != ComboBuyCount[1] && ComboBuyCount[1 ] < 10 && ComboBuyCount > 0 then ComboBuyCount else if TDTerminationIICountBuy[ 1] > 0 && TDTerminationIICountBuy == 2 then 13 else ComboBuyCountDown[1]. plot ComboCountSubStart = if onetonineAX != onetonineAX[1] && onetonineAX > 0 && onetonineAX[1] < 9 && ShowSubCounts then onetonineAX else Double.VALUES_ABOVE).rec AggBuyClose = if IsNaN(AggBuyClose[1]) or AutomaticRecycle then 0 else if Ag gBuyClose[1] < 1 && ComboBuyCount[1] < 10 && ComboBuyCount == 10 then close else if AggBuyClose[1] > 1 && close < AggBuyClose[1] then close else if ComboBuyCount[1 ] < 1 then 0 else AggBuyClose[1]. plot ComboCountStart = if onetonineA != onetonineA[1] && onetonineA > 0 && oneto nineA[1] < 9 && ShowFirst then onetonineA else Double. case "TDTermination": ComboBuyCountDown = if ComboBuyCount != ComboBuyCount[1] && ComboBuyCount[1] < 12 && ComboBuyCount > 0 then ComboBuyCount else if TDTerminationCountBuy[1] > 0 && TDTerminationCountBuy == 2 then 13 else ComboBuyCountDown[1]. rec AggBuyCount = if IsNaN(AggBuyCount[1]) or AutomaticRecycle then 0 else if Ag gBuyCount[1] < 1 && ComboBuyCount[1] < 10 && ComboBuyCount == 10 then 10 else if AggBuyCount[1] >= 10 && AggBuyClose < AggBuyClose[1] then AggBuyCount[1] + 1 el se if AggBuyCount[1] >= 13 then 0 else AggBuyCount[1].VALUES_BELOW).NaN. ComboCountStart.NaN. rec ComboBuyCountDown. 33)).SetPaintingStrategy(PaintingStrategy. } plot BuyComboCountDown = if ComboBuyCountDown != ComboBuyCountDown[1] then Combo BuyCountDown else Double. 215. rec AggBuyCountii = if IsNaN(AggBuyCountii[1]) or AutomaticRecycle then 0 else i f AggBuyCountii[1] < 1 && ComboBuyCount[1] < 10 && ComboBuyCount == 10 then 10 e lse if AggBuyCountii[1] >= 10 && AggBuyCountii[1] < 12 && AggBuyClose < AggBuyCl ose[1] then AggBuyCountii[1] + 1 else if AggBuyCountii[1] >= 13 then 0 else AggB uyCountii[1]. rec TDTerminationIICountBuy = if AutomaticRecycle then 0 else if ComboBuyCount[1 ] < 12 && ComboBuyCount == 12 && TDTerminationIICountBuy[1] < 1 then 1 else if T DTerminationIICountBuy[1] == 1 && (open <= CountPrice[1] or close <= CountPrice[ 1]) then 2 else if TDTerminationCountBuy[1] >= 2 then 0 else TDTerminationCountB uy[1]. BuyComboCountDown. case "Two": ComboBuyCountDown = if ComboBuyCount != ComboBuyCount[1] && ComboBuyCount[1] < 10 && ComboBuyCount > 0 then ComboBuyCount else if AggBuyCount != AggBuyCount [1] && AggBuyCount > 0 && AggBuyCount <= 13 then AggBuyCount else ComboBuyCountD own[1].

def V3X. } rec CountPriceNewSellSetup. VComboX = V1X && V2X && V3X. def QualifySellCountPrice = if VComboX && CountPriceX[1] < 1 then 1 else if C . rec CountPriceX. } def QualNewSellCountPrice = CounterB >= 1 && CounterB <= 9 && CountPriceNewSellS etup != CountPriceNewSellSetup[1] && VComboX.ComboCountSubStart. def VComboX.VALUES_ABOVE). def V2X. case Aggressive: CountPriceX = if AutomaticRecycleX or (CounterB == 1 && SellSetupCt[1] < 1) then 0 else if VComboX && CountPriceX[1] < 1 then high else if VComboX && high > CountPriceX[1] && CountPriceX[1] > 1 then high else CountPriceX[1]. } def AutomaticRecycleX = (B == 9 && B[1] != 9) or (truehigh < TDSTSupport[1] && TDSTSupport[1] != 0). VComboX = V1X && V2X && V3X. def V1X. switch (ComboType) { case Traditional: CountPriceX = if AutomaticRecycleX or (CounterB == 1 && SellSetupCt[1] < 1) then 0 else if VComboX && CountPriceX[1] < 1 then close else if VComboX && close > CountPriceX[1] && CountPriceX[1] > 1 then close else CountPriceX[1]. case Aggressive: V1X = high >= high[2]. V3X = close > close[1].SetPaintingStrategy(PaintingStrategy. case Aggressive: CountPriceNewSellSetup = if IsNaN(CountPriceNewSellSetup[1]) or AutomaticRec ycleX then 0 else if CountPriceNewSellSetup[1] < 1 && CounterB == 1 && VComboX & & SellSetupCt[1] >= 1 then high else if CountPriceNewSellSetup[1] < 1 && Counter B == 1 && SellSetupCt[1] >= 1 && !VComboX then 1 else if CounterB > 1 && Counter B <= 9 && CountPriceNewSellSetup[1] == 1 && VComboX && SellSetupCt[1] >= 1 then high else if CounterB > 1 && CounterB <= 9 && CountPriceNewSellSetup[1] > 1 && h igh > CountPriceNewSellSetup[1] && SellSetupCt[1] >= 1 then high else if S[1] == 9 && SellSetupCt[1] >= 2 then 0 else CountPriceNewSellSetup[1]. switch (ComboType) { case Traditional: CountPriceNewSellSetup = if IsNaN(CountPriceNewSellSetup[1]) or AutomaticRec ycleX then 0 else if CountPriceNewSellSetup[1] < 1 && CounterB == 1 && VComboX & & SellSetupCt[1] >= 1 then close else if CountPriceNewSellSetup[1] < 1 && Counte rB == 1 && SellSetupCt[1] >= 1 && !VComboX then 1 else if CounterB > 1 && Counte rB <= 9 && CountPriceNewSellSetup[1] == 1 && VComboX && SellSetupCt[1] >= 1 then close else if CounterB > 1 && CounterB <= 9 && CountPriceNewSellSetup[1] > 1 && close > CountPriceNewSellSetup[1] && SellSetupCt[1] >= 1 then close else if S[1 ] == 9 && SellSetupCt[1] >= 2 then 0 else CountPriceNewSellSetup[1]. V3X = high > high[1]. switch (ComboType) { case Traditional: V1X = close >= high[2]. V2X = high >= high[1]. V2X = high >= high[1].

ComboSellCount != ComboSellCount[1] && ComboSellCoun > 0 then ComboSellCount else if AggSellCount != AggS . switch (CountDownType) { case "One": ComboSellCountDown = if t[1] < 13 && ComboSellCount case "Two": ComboSellCountDown = if t[1] < 10 && ComboSellCount ComboSellCount != ComboSellCount[1] && ComboSellCoun > 0 then ComboSellCount else ComboSellCountDown[1]. def VComboBX = VComboX && QualifySellCountPrice. #combosellcount. was combobuycountdown rec TDTermCountSell = if AutomaticRecycle then 0 else if Combosellcount[1] < 12 && CombosellCount == 12 && TDTermCountSell[1] < 1 then 1 else if TDTermCountSell [1] == 1 && (open >= CountPriceX[1] or close >= CountPriceX[1]) then 2 else if T DTermCountSell[1] >= 2 then 0 else TDTermCountSell[1]. rec OneToNineB = if IsNaN(OneToNineB[1]) then 0 else if CounterB == 1 && VComboB X then 1 else if CounterB > 1 && CounterB[1] < 9 && VComboBX then OneToNineB[1 ] + 1 else if S[1] == 9 then 0 else OneToNineB[1]. rec ComboSellCount = if IsNaN(ComboSellCount[1]) or (ComboSellCount[1] == 13 ) o r AutomaticRecycleX then 0 else if ComboSellCount[1] < 1 && S == 9 && S[1] != 9 && VComboBX then OneToNineB[1] + 1 else if ComboSellCount[1] < 1 && S == 9 && S[1] != 9 && !VComboBX then OneToNineB[1] else if ComboSellCount[1] > 0 && VCom boBX && S != 9 then ComboSellCount[1] + 1 else if ComboSellCount[1] > 0 && S == 9 && S[1] != 9 && SellSetupCt[1] >= 1 && SellSetupCt > SellSetupCt[1] && (getTR X > prevTRX) && CounterXX == 9 && VComboBXX then OneToNineBX[1] + 1 else if ComboSellCount[1] > 0 && S == 9 && S[1] != 9 && SellSetupCt[1] >= 1 && SellSetupCt > SellSetupCt[ 1] && (getTRX > prevTRX) && CounterXX == 9 && !VComboBXX then OneToNineBX[1] els e if ComboSellCount[1] > 0 && S == 9 && S[1] != 9 && SellSetupCt > SellSetupCt[ 1] && (getTRX < prevTRX) && VComboBX && SellSetupCt[1] >= 1 then ComboSellCount[ 1] + 1 else if ComboSellCount[1] > 0 && S == 9 && S[1] != 9 && SellSetupCt > Sel lSetupCt[1] && (getTRX < prevTRX) && !VComboBX && SellSetupCt[1] >= 1 then Combo SellCount[1] else ComboSellCount[1]. rec AggSellClose = if IsNaN(AggSellClose[1]) or AutomaticRecycle then 0 else if AggSellClose[1] < 1 && ComboSellCount[1] < 10 && ComboSellCount == 10 then close else if AggSellClose[1] > 1 && close > AggSellClose[1] then close else if ComboSellCoun t[1] < 1 then 0 else AggSellClose[1]. def VComboBXX = VComboX && QualNewSellCountPrice. rec OneToNineBX = if IsNaN(OneToNineBX[1]) then 0 else if CounterB == 1 && VComb oBXX && SellSetupCt[1] >= 1 then 1 else if CounterB > 1 && CounterB <= 9 && VCom boBXX && SellSetupCt[1] >= 1 then OneToNineBX[1] + 1 else if S[1] == 9 then 0 else OneToNineBX[1]. rec AggSellCount = if IsNaN(AggSellCount[1]) or AutomaticRecycle then 0 else if AggSellCount[1] < 1 && ComboSellCount[1] < 10 && ComboSellCount == 10 then 10 el se if AggSellCount[1] >= 10 && AggSellClose > AggSellClose[1] then AggSellCount[1] + 1 else if AggSellCount[1] >= 13 then 0 else AggSellCount[1].ountPriceX > CountPriceX[1] && VComboX then 1 else if CounterB == 1 && SellSet upCt[1] < 1 then 1 else 0. rec ComboSellCountDown.

20).VALUES_ABOVE). rec TDComboBuyRiskLevel = if IsNaN(TDComboBuyRiskLevel[1]) then 0 else if Comb oBuyCount == 13 && ComboBuyCount[1] < 13 then LLTL . 227)).SetPaintingStrategy(PaintingStrategy. SellComboCountDown.VALUES_BELOW). TDComboSellCountDownRiskLevel. GetMinValueOffset(TrueLow. case "TDTermination": ComboSellCountDown = if ComboSellCount != ComboSellCount[1] && ComboSellCoun t[1] < 12 && ComboSellCount > 0 then ComboSellCount else if TDTermCountSell[1] > 0 && TDTermCountSell == 2 then 13 else ComboSellCountDown[1].NaN.ellCount[1] && AggSellCount > 0 && AggSellCount <= 13 then AggSellCount else Com boSellCountDown[1]. SellComboCountDown.SetDefaultColor(CreateColor(255.SetPaintingStrategy(PaintingStrategy. TDComboSellCountDownRiskLevel.DASHES). TDComboBuyCountDownRiskLevel. def HHTH = GetValue(truehigh. GetMinValueOffset(TrueLow. ComboSellCountStart. 20). plot TDComboBuyCountDownRiskLevel = if !showrisklevels && TDComboBuyRiskLevel > 0 && ctrisk > 0 then TDComboBuyRiskLevel else Double. plot BuyThirteenArrow = if (combobuycountdown == 13) && (combobuycountdown[1] != . def LLTL = GetValue(TrueLow.NaN. plot ComboCountSellSubStart = if OneToNineBX != OneToNineBX[1] && OneToNineBX > 0 && OneToNineBX[1] < 9 && ShowSubCounts then OneToNineBX else Double. ComboCountSellSubStart.HideBubble().LLTL) else TDComboB uyRiskLevel[1].SetPaintingStrategy(PaintingStrategy. 15. rec ctrisk = if IsNaN(ctrisk[1]) then 0 else if ctrisk[1] >= riskbars then 0 els e if ComboBuyCount == 13 && ComboBuyCount[1] < 13 then 1 else if ctrisk[1] >= 1 && ctrisk[1] <= riskbars then ctrisk[1] + 1 else ctrisk[1].VALUES_BELOW). def HHTL = GetValue(TrueLow.DASHES). plot ComboSellCountStart = if OneToNineB != OneToNineB[1] && OneToNineB > 0 && O neToNineB[1] < 9 && ShowFirst then OneToNineB else Double. 20). 20). 20). GetMaxValueOffset(truehigh.HideBubble(). 20).(LLTH . 20).NaN.NaN.SetPaintingStrategy(PaintingStrategy. TDComboSellCountDownRiskLevel.SetPaintingStrategy(PaintingStrategy. 192)). plot TDComboSellCountDownRiskLevel = if TDComboSellRiskLevel > 0 && !showrisklev els && ctriskX > 0 then TDComboSellRiskLevel else Double. TDComboBuyCountDownRiskLevel. 231)).NaN.SetDefaultColor(CreateColor(44. rec ctriskX = if IsNaN(ctriskX[1]) then 0 else if ctriskX[1] >= riskbars then 0 else if ComboSellCount == 13 && ComboSellCount[1] < 13 then 1 else if ctriskX[ 1] >= 1 && ctriskX[1] <= riskbars then ctriskX[1] + 1 else ctriskX[1]. 71.HHTL) else TDCo mboSellRiskLevel[1]. rec TDComboSellRiskLevel = if IsNaN(TDComboSellRiskLevel[1]) then 0 else if Co mboSellCount == 13 && ComboSellCount[1] < 13 then HHTH + (HHTH . } plot SellComboCountDown = if ComboSellCountDown != ComboSellCountDown[1] AND Com bosellcountdown[1] != 13 then ComboSellCountDown else Double. 20). GetMaxValueOffset(truehigh.SetDefaultColor(CreateColor(252. def LLTH = GetValue(truehigh. TDComboBuyCountDownRiskLevel. 251.

AddLabel(if showlabel then yes else no. BuyThirteenArrow.Tr ueLow[1])) && high > TDComboSellRiskLevel[1] + .ARROW_UP).. rec qual2bo = if IsNaN(qual2bo[1]) then 0 else if ComboSellCount[1] < 13 && Comb oSellCount == 13 then 1 else if qual2bo[1] == 1 && ctriskX[1] <= riskbars && TDC omboSellRiskLevel[1] > 0 && close[1] < TDComboSellRiskLevel[1] && open > TDCombo SellRiskLevel[1] && open > close[1] then 2 else if qual2bo[1] >= 2 then 0 else qual2bo[1].(truehigh[1] . rec qual2boX = if IsNaN(qual2boX[1]) then 0 else if ComboBuyCount[1] < 13 && Com boBuyCount == 13 then 1 else if qual2boX[1] == 1 && ctrisk[1] <= riskbars && TDC omboBuyRiskLevel[1] > 0 && close[1] > TDComboBuyRiskLevel[1] && open <= TDComboB uyRiskLevel[1] .Offset else Double. 98)).01 then 2 else if qu al1bo[1] >= 2 then 0 else qual1bo[1]. plot SellThirteenArrow = if (comboSellCountDown == 13) && (comboSellCountDown[1] != 13) then High + offset else Double. Color. qualboup..01 then 2 else if qual3bo[1] >= 2 then 0 else qual3bo[1]. rec qual1boX = if IsNaN(qual1boX[1]) then 0 else if ComboBuyCount[1] < 13 && Com boBuyCount == 13 then 1 else if qual1boX[1] == 1 && ctrisk[1] > 0 && close[1] > TDComboBuyRiskLevel[1] && TDComboBuyRiskLevel[1] > 0 && close[1] > close[2] && low <= TDComboBuyRiskLevel[1] .SetPaintingStrategy(PaintingStrategy. rec qual1bo = if IsNaN(qual1bo[1]) then 0 else if ComboSellCount[1] < 13 && Comb oSellCount == 13 then 1 else if qual1bo[1] == 1 && ctriskX[1] > 0 && close[1] < TDComboSellRiskLevel[1] && TDComboSellRiskLevel[1] > 0 && close[1] < close[2] && high > TDComboSellRiskLevel[1] + .01 then 2 else if qua l1boX[1] >= 2 then 0 else qual1boX[1]. Color.close[1])) && low <= TDComboBuyRiskLevel[1] .SetPaintingStrategy(PaintingStrategy.SetDefaultColor(Color.NaN.RED).NaN..if ComboSellCount down >= 10 then combosellcountdown else combosellcount).SetDefaultColor(CreateColor(0. 255. BuyThirteenArrow. qualboup.13) then Low . plot qualbodown = if (qual1boX[1] == 1 && qual1boX > 1) or (qual2boX[1] == 1 && . SellThirteenArrow.ARROW_DOWN).TRIANGLES).SetLineWeight(5). rec qual3boX = if IsNaN(qual3boX[1]) then 0 else if ComboBuyCount[1] < 13 && Com boBuyCount == 13 then 1 else if qual3boX[1] == 1 && ctrisk[1] <= riskbars && TDC omboBuyRiskLevel[1] > 0 && close[1] > TDComboBuyRiskLevel[1] && TDComboBuyRiskLe vel[1] < (close[1] .NaN. Concat("ComboBuy = " . rec qual3bo = if IsNaN(qual3bo[1]) then 0 else if ComboSellCount[1] < 13 && Comb oSellCount == 13 then 1 else if qual3bo[1] == 1 && ctriskX[1] <= riskbars && TDC omboSellRiskLevel[1] > 0 && TDComboSellRiskLevel[1] > (close[1] + (close[1] .01 then 2 else if qual3boX[1] >= 2 then 0 else qual3boX[1].GREEN). SellThirteenArrow.WHITE).SetPaintingStrategy(PaintingStrategy. Concat("ComboSell = ". 25. qualboup.01 && open < close[1] then 2 else if qual2boX[1] >= 2 then 0 else qual2boX[1]. 0)).if ComboBuyCountd own >= 10 then combobuycountdown else combobuycount).offset else Double. plot qualboup = if (qual1bo[1] == 1 && qual1bo > 1) or (qual2bo[1] == 1 && qual2 bo > 1) or (qual3bo[1] == 1 && qual3bo > 1) then TDComboSellRiskLevel .SetDefaultColor(CreateColor(255. AddLabel(if showlabel then yes else no.

NaN. switch (TDCamoType) { case None: UPcam = Double. input TDCamoType = {default "None". DownCam = if shouldplotX && high >= high[1] and close >= close[1] and close <= open then (high + Offset) else Double. "Both"}.NaN. rec ComboBuyBarCt = if ComboBuyCount == 13 && ComboBuyCount[1] < 13 && ComboBuy BarCt[1] <= MaxBars then 1 else if ComboBuyBarCt[1] >= 1 && ComboBuyBarCt[1] <= MaxBars then ComboBuyBarCt[1] + 1 else if ComboBuyBarCt[1] >= MaxBars then 0 el se ComboBuyBarCt[1]. rec sellctsignalct = if IsNaN(sellctsignalct[1]) then 0 else if sellctsignalct[ 1] >= MaxBars then 0 else if ComboSellCount == 13 && ComboSellCount[1] != 13 then 1 else if sellctsignalct[1] >= 1 && sellctsignalct[1] <= MaxBars then sell ctsignalct[1] + 1 else sellctsignalct[1]. rec CombSellBarCt = if ComboSellCount == 13 && ComboSellCount[1] < 13 && CombSe llBarCt[1] <= MaxBars then 1 else if CombSellBarCt[1] >= 1 && CombSellBarCt[1] <= MaxBars then CombSellBarCt[1] + 1 else if CombSellBarCt[1] >= MaxBars then 0 else CombSellBarCt[1].SetDefaultColor(Color.NaN.NaN. "Both"}. #hint MaxBars: The number of bars following a completed countdownType in either direction for which then TD Confirmation Signals will plot. rec buyctsignalct = if IsNaN(buyctsignalct[1]) then 0 else if buyctsignalct[1] >= MaxBars then 0 else if ComboBuyCount == 13 && ComboBuyCount[1] != 13 then 1 else if buyctsignalct[1] >= 1 && buyctsignalct[1] <= MaxBars then buycts ignalct[1] + 1 else buyctsignalct[1].qual2boX > 1) or (qual3boX[1] == 1 && qual3boX > 1) then TDComboBuyRiskLevel + Offset else Double. DownCam = Double. input MaxBars = 5. "Up". plot TDOpenSell.NaN. qualbodown. DownCam = Double. case "Up": UPcam = if shouldplot && low <= low[1] and close <= close[1] and close >= op en then (low . DownCam = if shouldplotX && high >= high[1] and close >= close[1] and close <= open then (high + Offset) else Double. "Down". } #hint TDOpenType: TDOpen Buy/Sell Sequential Confirmation signals. "Down". qualbodown. case "Down": UPcam = Double.NaN. plot DownCam. case "Both": UPcam = if shouldplot && low <= low[1] and close <= close[1] and close >= op en then (low .Offset) else Double. def shouldplotX = sellctsignalct[1] > 0 or CombSellBarCt[1] > 0 .TRIANGLES). def shouldplot = buyctsignalct[1] > 0 or ComboBuyBarCt[1] > 0 . input TDOpenType = {default "None". plot TDOpenBuy.NaN.SetPaintingStrategy(PaintingStrategy. qualbodown.WHITE). #hint TDCamoType: Show TDCamoflage Buy/Sell Sequential Confirmation signals. plot UPcam.NaN. "Up".Offset) else Double.NaN. .SetLineWeight(5).

NaN.NaN. plot TDClopSell.NaN. open[1]) then high + Offset else Double. TDClopSell = Double.NaN.switch (TDOpenType) { case None: TDOpenBuy = Double.NaN.Offset else Double.NaN. } #hint TDClopWinType: TDClopWin Buy/Sell Sequential Confirmation signals. TDClopWinSell = if shouldplotX && TDClopWin && close < open then high + Offs . TDClopWinSell = Double.NaN.NaN. "Both"}. case Down: TDClopWinBuy = Double. open[1]).NaN. "Down". open[1]) && close >= Min(close[1]. case Up: TDClopBuy = if shouldplot && open <= close[1] and open <= open[1] && high > Max(close[1]. "Down".Offset else Double.NaN.NaN.NaN. } low[1] && high > (low[1]) then low . plot TDClopBuy. switch (TDClopType) { case None: TDClopBuy = Double. TDOpenSell = Double. plot TDClopWinSell. def TDClopWin = open <= Max(close[1]. TDClopSell = if shouldplotX && open >= close[1] and open >= open[1] && low < Min(close[1]. TDClopWinSell = Double. case Down: TDClopBuy = Double. input TDClopType = {default "None". case Up: TDClopWinBuy = if shouldplot && TDClopWin && close > open then low . TDClopSell = if shouldplotX && open >= close[1] and open >= open[1] && low < Min(close[1]. case Down: TDOpenBuy = Double. switch (TDClopWinType) { case None: TDClopWinBuy = Double.Offset else Double. open[1]) then low . input TDClopWinType = {default "None". case Both: TDClopBuy = if shouldplot && open <= close[1] and open <= open[1] && high > Max(close[1]. "Both"}.Off > high[1] && low < (high[1]) then high + #hint TDClopType: TDClop Buy/Sell Sequential Confirmation signals.NaN. TDClopSell = Double. "Up". TDOpenSell = if shouldplotX && open Offset else Double. case Up: TDOpenBuy = if shouldplot && open < set else Double. open[1]) && open >= Min(close[1]. open[1]) && close <= Max(close[1]. TDOpenSell = if shouldplotX && open Offset else Double.NaN.NaN.NaN.NaN.NaN. plot TDClopWinBuy.NaN. open[1]) then high + Offset else Double.Off > high[1] && low < (high[1]) then high + low[1] && high > (low[1]) then low . open[1]) then low . case Both: TDOpenBuy = if shouldplot && open < set else Double.NaN. TDOpenSell = Double. "Up".NaN.

177. .ARROW_DOWN). } #hint TDTrapType: TDTrap Buy/Sell Sequential Confirmation signals.ARROW_DOWN).NaN. TDClopSell. 247)).SetDefaultColor(CreateColor(54.SetPaintingStrategy(PaintingStrategy. 247)).Offset else Double.NaN. TDTrapSell = Double.ARROW_UP).NaN. TDClopWinBuy.NaN. "Down". 24. case Up: TDTrapBuy = if shouldplot && open >= low[1] && open <= high[1] && high > hig h[1] then low . TDClopSell.NaN.SetDefaultColor(CreateColor(0.ARROW_UP).ARROW_DOWN). 255)).SetDefaultColor(CreateColor(54. 255)).SetPaintingStrategy(PaintingStrategy.NaN. case Both: TDTrapBuy = if shouldplot && open >= low[1] && open <= high[1] && high > hig h[1] then low . 255)).SetDefaultColor(CreateColor(0. 24.SetDefaultColor(CreateColor(54. input TDTrapType = {default "None". TDClopWinSell. 24. UPcam. 247)).NaN.et else Double. 255)).SetDefaultColor(CreateColor(0.SetPaintingStrategy(PaintingStrategy.NaN. TDTrapBuy.SetDefaultColor(CreateColor(54. plot TDTrapBuy. TDTrapSell = if shouldplotX && open >= low[1] && open <= high[1] && low < lo w[1] then high + Offset else Double.SetPaintingStrategy(PaintingStrategy.Offset else Double. 24. TDClopWinSell. 247)).SetPaintingStrategy(PaintingStrategy. 24.NaN. TDOpenBuy.Offset else Double.SetDefaultColor(CreateColor(0. plot TDTrapSell. 177. 255)).SetPaintingStrategy(PaintingStrategy.SetPaintingStrategy(PaintingStrategy. DownCam. TDTrapSell. } TDTrapBuy. case Down: TDTrapBuy = Double.SetPaintingStrategy(PaintingStrategy. DownCam.SetPaintingStrategy(PaintingStrategy. "Up".NaN. TDClopBuy. TDClopWinBuy. 177.ARROW_DOWN). TDTrapSell. switch (TDTrapType) { case None: TDTrapBuy = Double. TDClopWinSell = if shouldplotX && TDClopWin && close < open then high + Offs et else Double.ARROW_UP).SetPaintingStrategy(PaintingStrategy. "Both"}. TDOpenSell. case Both: TDClopWinBuy = if shouldplot && TDClopWin && close > open then low .SetDefaultColor(CreateColor(54. TDTrapSell = Double.SetDefaultColor(CreateColor(0. TDOpenBuy. 247)). 177. TDTrapSell = if shouldplotX && open >= low[1] && open <= high[1] && low < lo w[1] then high + Offset else Double.ARROW_UP).NaN. TDOpenSell. 177.ARROW_DOWN). TDClopBuy.ARROW_UP). UPcam.