ChiliPepper
New member
Here's the updated code below:Is the above code updated to reflect this update ?
#Start_TMO_CODE_Created_By_Mobius**********
#Found here https://usethinkscript.com/threads/tmo-true-momentum-oscillator-for-thinkorswim.9413/
# TMO ((T)rue (M)omentum (O)scilator)
# Mobius
# V01.05.2018
# hint: TMO calculates momentum using the delta of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.
def length = 14;
def calcLength = 5;
def smoothLength = 3;
def o = open;
def c = close;
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i) then 1 else if c < getValue(o, i) then - 1 else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
def zero = if isNaN(c) then double.nan else 0;
def ob = if isNaN(c) then double.nan else round(length * .7);
def os = if isNaN(c) then double.nan else -round(length * .7);
#End_TMO_CODE*_Created_By_Mobius***********
#****************************************************************************************************
#Defining Conditions - a change in momemtum and TMO os/ob levels
#Bullish Signal
def SH = TTM_Squeeze().Histogram;
def HistogramUp = if SH[0] > SH[1] then 1 else 0;
def TMO_MomentumUp = Main <= os and HistogramUP or Main <=os and HistogramUp;
def BullSignal = !TMO_MomentumUp[1] and TMO_MomentumUp;
#Bearish Signal
def HistogramDown = if SH[0] < SH[1] then 1 else 0;
def TMO_MomentumDown = Main >= ob and HistogramDown or Main >=ob and HistogramDown;
def BearSignal = !TMO_MomentumDown[1] and TMO_MomentumDown;
AddLabel(yes, if BullSignal then "Calls" else if BearSignal then "Puts" else " ");
AddLabel(BullSignal, "Calls", color.black);
AddLabel(BearSignal, "Puts", color.black);
AssignBackgroundColor(if BullSignal then color.light_green else if BearSignal then color.pink else color.black);