TMO True Momentum Oscillator For ThinkOrSwim

I still get Exactly one plot expected error. The formula won't compile. Any help will be appreciated.
Sorry, didn't realize you were using the "stuff the whole code into scan hacker" method vs "saving it as a study as referencing it in scan hacker" method.

The above post has been edited to work with your method of scan hacking (y)
 
True momentum oscillator divergence?
I love to use divergence on the TMO, especially from over bought or over sold levels for trend reversal on lower charts. Can anyone add divergence to the TMO indicator or point me to a good divergence indicator I can use to convert?
Thanks
 
True momentum oscillator divergence?
I love to use divergence on the TMO, especially from over bought or over sold levels for trend reversal on lower charts. Can anyone add divergence to the TMO indicator or point me to a good divergence indicator I can use to convert?
Thanks
These are the Top 20 Divergence Indicators on the Forum
For the most part, computer-generated divergence indicators do not work well. Although some members seem to like Peter Hahn's commercial divergence indicator.
 
TMO divergence indicator.
Made from Bens MACD divergence indicator. https://usethinkscript.com/threads/macd-divergence-indicator-for-thinkorswim.35/
Code:
input length = 14;
input calcLength = 5;
input smoothLength = 3;
input bar = 2;

def o = open;
def c = close;
def data = fold ii = 0 to length
           with s
           do s + (if c > getValue(o, ii)
                   then 1
                   else if c < getValue(o, ii)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
plot Main = ExpAverage(EMA5, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
     Main.AssignValueColor(if Main > Signal
                           then color.green
                           else color.red);
     Signal.AssignValueColor(if Main > Signal
                             then color.green
                             else color.red);
     Signal.HideBubble();
     Signal.HideTitle();
addCloud(Main, Signal, color.green, color.red);
plot zero = if isNaN(c) then double.nan else 0;
     zero.SetDefaultColor(Color.gray);
     zero.hideBubble();
     zero.hideTitle();
plot ob = if isNaN(c) then double.nan else round(length * .7);
     ob.SetDefaultColor(Color.gray);
     ob.HideBubble();
     ob.HideTitle();
plot os = if isNaN(c) then double.nan else -round(length * .7);
     os.SetDefaultColor(Color.gray);
     os.HideBubble();
     os.HideTitle();
addCloud(ob, length, color.light_red, color.light_red, no);
addCloud(-length, os, color.light_green, color.light_green);
# End Code TMO

plot Diff = Main;

def SwingHigh = Diff > 0 and Diff >= highest(Diff[1], bar) and Diff >= highest(Diff[-bar], bar);

def SHprice = if SwingHigh then Diff else SHprice[1];

def SHBar = if SwingHigh then BarNumber() else SHBar[1];

def CrossBarL = if Diff crosses below 0 then BarNumber() else CrossBarL[1];

def SwingLow = Diff < 0 and Diff <= lowest(Diff[1], bar) and Diff <= lowest(Diff[-bar], bar);

def SLprice = if SwingLow then Diff else SLprice[1];

def SLBar = if SwingLow then BarNumber() else SLBar[1];

def CrossBarH = if Diff crosses above 0 then BarNumber() else CrossBarH[1];

def SHSP = if SwingHigh then high else SHSP[1];

def SLSP = if SwingLow then low else SLSP[1];

def BearDiv = Diff > 0 and CrossBarL[1] > SHBar[1] and Diff < SHprice[1] and high > SHSP[1] and SHprice[1] - Diff > 0.005;

def BullDiv = Diff < 0 and CrossBarH[1] > SLBar[1] and Diff > SLprice[1] and low < SLSP[1] and Diff - SLprice[1] > 0.005;

def HiddenBearDiv = Diff > 0 and Diff > SHprice[1] and high < SHSP[1] and Diff - SHprice[1] > 0.005;

def HiddenBullDiv = Diff < 0 and Diff < SLprice[1] and low > SLSP[1] and SLprice[1] - Diff > 0.005;

plot BearD = if BearDiv then high else Double.NaN;

        BearD.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

        BearD.AssignValueColor(Color.RED);

        BearD.SetLineWeight(3);

plot BullD = if BullDiv then low else Double.NaN;

        BullD.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

        BullD.AssignValueColor(Color.UPTICK);

        BullD.SetLineWeight(3);

plot HiddenBearD = if HiddenBearDiv then high else Double.NaN;

        HiddenBearD.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

        HiddenBearD.AssignValueColor(Color.PINK);

        HiddenBearD.SetLineWeight(1);

plot HiddenBullD = if HiddenBullDiv then low else Double.NaN;

        HiddenBullD.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

        HiddenBullD.AssignValueColor(Color.LIME);

        HiddenBullD.SetLineWeight(1);

Alert(BearDiv[1], "Short MACD divergence", Alert.BAR, Sound.Ring);

Alert(BullDiv[1], "Long MACD divergence", Alert.BAR, Sound.Ring);

Alert(HiddenBearDiv[1], "Short hidden MACD divergence", Alert.BAR, Sound.Ring);

Alert(HiddenBullDiv[1], "Long hidden MACD divergence", Alert.BAR, Sound.Ring);
 
@MerryDay I was using the TMO label script that you created and I like what it shows, was wondering if there's a way to scan for the yellow and or orange candles. Or if this is even possible to do. What you think?

TMO ((T)rue (M)omentum (O)scilator) Scan Scanner

Ruby:
# TMO ((T)rue (M)omentum (O)scilator) Scan
# Mobius, with modifications by tomsk, 1.1.2020
# 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.

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input level = -15;   ##Bullish Scan
#input level = 10;   ##Bearish Scan

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);

##***Bullish Scan***
plot scan = main < -10 and main>main[1] ;
@MerryDay on you colored labels can this scan show the trend begin and trend end candles. Have a watchlist that basically shows but wanting to scan for those candles in general from time to time
 
Last edited by a moderator:
@MerryDay I was using the TMO label script that you created and I like what it shows, was wondering if there's a way to scan for the yellow and or orange candles. Or if this is even possible to do. What you think?

Ruby:
# TMO ((T)rue (M)omentum (O)scilator) Scan
# Mobius, with modifications by tomsk, 1.1.2020
# 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.

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input level = -15;   ##Bullish Scan
#input level = 10;   ##Bearish Scan

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 ob = if isNaN(c) then double.nan else round(length * .7);
def os = if isNaN(c) then double.nan else -round(length * .7);

##***Maxxed and TrendEnd Scan***
plot YellowOrangeSCAN =
main > ob   or
main crosses below ob ;
 
Last edited:
Ruby:
# TMO ((T)rue (M)omentum (O)scilator) Scan
# Mobius, with modifications by tomsk, 1.1.2020
# 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.

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input level = -15;   ##Bullish Scan
#input level = 10;   ##Bearish Scan

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 ob = if isNaN(c) then double.nan else round(length * .7);
def os = if isNaN(c) then double.nan else -round(length * .7);

##***Maxxed and TrendEnd Scan***
plot YellowOrangeSCAN =
main > ob   or
main crosses below ob ;

@MerryDay you're the GOAT. I meant to say or at least I thought I sent it but how would you word this for only trend end and trend begin candles? I think my original question got merged but I was trying to reword what I actually wanted to see from the scanner. So its the blue and yellow candle wish I knew how to switch it :) other than this request I'll sit on my hands until the S&D indicator finishes cooking up thanks for all you do. Maxxed is cool but you may be on watch for awhile so can you swap it for trend begin instead :)
 
Last edited by a moderator:
how would you word this for only trend end and trend begin candles?
put this at the bottom of your scan study:
Ruby:
##***TrendBegin and TrendEnd Scan***
plot BeginEndSCAN =
main crosses above os   or
main crosses below ob ;
 
Can make any change to the TMO indicator such as a red on the top and green bar at the bottom be there instead of slowly developing when the market moves.
Similar to Heiken ashi oscillator. thanks

# 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.

declare Lower;

input length = 14;
input calcLength = 5;
input 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);
plot Main = ExpAverage(EMA5, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
Main.AssignValueColor(if Main > Signal
then color.green
else color.red);
Signal.AssignValueColor(if Main > Signal
then color.green
else color.red);
Signal.HideBubble();
Signal.HideTitle();
addCloud(Main, Signal, color.green, color.red);
plot zero = if isNaN(c) then double.nan else 0;
zero.SetDefaultColor(Color.gray);
zero.hideBubble();
zero.hideTitle();
plot ob = if isNaN(c) then double.nan else round(length * .7);
ob.SetDefaultColor(Color.gray);
ob.HideBubble();
ob.HideTitle();
plot os = if isNaN(c) then double.nan else -round(length * .7);
os.SetDefaultColor(Color.gray);
os.HideBubble();
os.HideTitle();
addCloud(ob, length, color.light_red, color.light_red, no);
addCloud(-length, os, color.light_green, color.light_green);
# End Code TMO
 
Can make any change to the TMO indicator such as a red on the top and green bar at the bottom be there instead of slowly developing when the market moves.
Similar to Heiken ashi oscillator. thanks

# 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.

declare Lower;

input length = 14;
input calcLength = 5;
input 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);
plot Main = ExpAverage(EMA5, smoothLength);
plot Signal = ExpAverage(Main, smoothLength);
Main.AssignValueColor(if Main > Signal
then color.green
else color.red);
Signal.AssignValueColor(if Main > Signal
then color.green
else color.red);
Signal.HideBubble();
Signal.HideTitle();
addCloud(Main, Signal, color.green, color.red);
plot zero = if isNaN(c) then double.nan else 0;
zero.SetDefaultColor(Color.gray);
zero.hideBubble();
zero.hideTitle();
plot ob = if isNaN(c) then double.nan else round(length * .7);
ob.SetDefaultColor(Color.gray);
ob.HideBubble();
ob.HideTitle();
plot os = if isNaN(c) then double.nan else -round(length * .7);
os.SetDefaultColor(Color.gray);
os.HideBubble();
os.HideTitle();
addCloud(ob, length, color.light_red, color.light_red, no);
addCloud(-length, os, color.light_green, color.light_green);
# End Code TMO

This is now a TMO histogram similar to what I have display for heikinashioscillator

Capture.jpg
Ruby:
# 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.

declare Lower;

input hide_signal_main = yes;
input length = 14;
input calcLength = 5;
input 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);
plot Main = ExpAverage(EMA5, smoothLength);
main.sethiding(hide_signal_main);
plot Signal = ExpAverage(Main, smoothLength);
Main.AssignValueColor(if Main > Signal
then color.green
else color.red);
Signal.AssignValueColor(if Main > Signal
then color.green
else color.red);
Signal.HideBubble();
Signal.HideTitle();
signal.sethiding(hide_signal_main);
addCloud(if (hide_signal_main) then double.nan else Main, Signal, color.green, color.red);
plot zero = if isNaN(c) then double.nan else 0;
zero.SetDefaultColor(Color.gray);
zero.hideBubble();
zero.hideTitle();
zero.sethiding(hide_signal_main);
plot ob = if isNaN(c) then double.nan else round(length * .7);
ob.SetDefaultColor(Color.gray);
ob.HideBubble();
ob.HideTitle();
ob.sethiding(hide_signal_main);
plot os = if isNaN(c) then double.nan else -round(length * .7);
os.SetDefaultColor(Color.gray);
os.HideBubble();
os.HideTitle();
os.sethiding(hide_signal_main);
addCloud(if (hide_signal_main) then double.nan else ob, length, color.light_red, color.light_red, no);
addCloud(if (hide_signal_main) then double.nan else -length, os, color.light_green, color.light_green);
plot tmohistogram = if signal then 1 else double.nan;
tmohistogram.assignvalueColor(if Main > Signal
then color.green
else color.red);
tmohistogram.setpaintingStrategy(paintingStrategy.HISTOGRAM);
# End Code TMO
 
I would like to create a simple label for the upper chart that displays current state of the main signal (cloud color) so when cloud is red, label will paint the same color. Anyone can help me with this? See code below

Code:
addCloud(Main, Signal, color.green, color.red);
 
I would like to create a simple label for the upper chart that displays current state of the main signal (cloud color) so when cloud is red, label will paint the same color. Anyone can help me with this? See code below

Code:
addCloud(Main, Signal, color.green, color.red);

Hi Zeek, I think the cloud is always the same color as the signal line, right? So I think the label would be:

Apache config:
AddLabel(yes,"TMO", if Main > Signal then color.green else color.red);

Hello everyone, I came into the thread because I wanted to ask for advice about re-scaling the TMO. The background of why I want to do this is in a thread I made inquiring about how to get the volume profile POC without generating a profile within the lower study which causes the study y-axis to re-scale to the range of the equity price. The lower study section includes a TMO plot within it and this is what gets crushed by the scaling issue (i.e., when I am able to call "GetPointofControl()" to use it as an input variable for part of the study I'm working on making, the y-axis while trading SPY goes up to 380+ and the TMO oscillator appears squished). Mobius suggested that if the volume profile POC scaling issue has no direct solution (which would be my first preference, to just get the VPOC without causing scaling problems, but I can't figure out a way to do this), then the TMO could be re-scaled to the same scale as the volume profile.

I thought the way to do this in the TMO code would be the following:

Change "input length = 14" to "def length = highest(close,14)"

Does that make sense? My only concern about this is that it seems like it would still make the scale look inconsistent. It could be visually confusing that for instance if SPY made a new high after 14 bars, the TMO plot for the preceding 14 bars would become squished by comparison with the more recent ones. Also, I'm not sure if dynamically defining the TMO input will make it run slower in my TOS, which is already pretty overloaded with processor intensive studies.

Someone in the Thinkscript Lounge chat room implied that the VPOC could be calculated or derived without generating a profile that would cause scaling problems but they didn't explain in more detail so I'm not sure if it's actually possible or practical. Mobius mentioned that the volume profile is made using javascript. That is probably why the "Hide()" function doesn't work on it, if it's like a plugin module that doesn't interact normally with the rest of thinkscript. So re-scaling the TMO to match the range of the volume profile may be my only solution to the problem. It just seems like a messy and convoluted solution. Do you guys have thoughts about this?

EDIT: to rescale the TMO to the SPY volume profile range, my idea to change "input length = 14" to "def length = high(close,14)" didn't work, I just tried it. The study no longer plots when that change is made.

EDIT 2: Mobius provided a version of TMO scaled to the price range of the stock chart:

Code:
script Scale
    {
    input c = close;
    def Min = LowestAll(close);
    def Max = HighestAll(close);
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}
# TMO ((T)rue (M)omentum (O)scillator)
# 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.

declare Lower;

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input AvgType = AverageType.Hull;
input ColorCandles = no;

def o = open;
def h = high;
def l = low;
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 scaledData = scale(data);
def EMA5 = Scale(ExpAverage(scaleddata, calcLength));
plot Main = MovingAverage(AvgType, EMA5, smoothLength);
def Signal = MovingAverage(AvgType, Main, smoothLength);
plot zero = if isNaN(c) then double.nan else HL2(period = "DAY");
     zero.SetDefaultColor(Color.gray);
     zero.hideBubble();
     zero.hideTitle();
def stat = if Main crosses Signal
           then barNumber()
           else stat[1];
 Main.SetPaintingStrategy(PaintingStrategy.Line);
 Main.AssignValueColor(if barNumber() >= highestAll(stat) and Main > Signal
                       then color.green
                       else if barNumber() >= highestAll(stat) and Main < Signal
                       then color.red
                       else color.gray);
 Main.HideBubble();
 Main.HideTitle();
# End Code TMO V01

def cond = getTime() crosses above RegularTradingStart(getYYYYMMDD());
profile vp = VolumeProfile("startNewProfile" = cond, "onExpansion" = no, numberOfProfiles = 1);
plot a = highestAll(if(isNaN(close[-1]), vp.GetPointOfControl(), double.nan));
     a.SetDefaultColor(Color.Cyan);
     a.SetLineWeight(3);
     a.HideBubble();
     a.HideTitle();
addChartBubble(barNumber() == highestAll(barNumber()), a, "POC", a.TakeValueColor());

It doesn't really solve my problem unfortunately because I need to use the the histogram painting strategy for the study I'm making that this was going to be part of. Re-scaling that way prevents the TMO from having a value range that goes from negative to positive. So again we're back to the wish that VPOC could be accessed without actually generating a profile, or while being able to fully hide the profile. But I shared this here in case anyone has a use for it. I think it could actually be useful to use the TMO with the VPOC overlapped on it.

EDIT: Just wanted to let everyone know that there was an incredibly elegant solution to enabling the re-scaling to work with a histogram plot. All it required was changing the scaling subscript in this way:

Replace ""def Min = LowestAll(close);" with ""def Min = LowestAll(close*-1);"

This is the whole scaling subscript to use if you need to rescale a histogram plot while preserving the shape with negative values:

Code:
script Scale
    {
    input c = close;
    def Min = LowestAll(close*-1);
    def Max = HighestAll(close);
    def hh = HighestAll(c);
    def ll = LowestAll(c);
    plot Range = (((Max - Min) * (c - ll)) /  (hh - ll)) + Min;
}

Hope this helps someone in the future!
 
Last edited:
Hi Zeek, I think the cloud is always the same color as the signal line, right? So I think the label would be:

Apache config:
AddLabel(yes,"TMO", if Main > Signal then color.green else color.red);

Hi @lmk99 and thank you for the help with the label, it works great!
Do you know if it´s possible to make this label display the TMO for a higher aggregation period than the one currently used? For example, let´s say i use a 5min chart and i want the label to display TMO from the 15min timeframe, is that possible?
 
Hi @lmk99 and thank you for the help with the label, it works great!
Do you know if it´s possible to make this label display the TMO for a higher aggregation period than the one currently used? For example, let´s say i use a 5min chart and i want the label to display TMO from the 15min timeframe, is that possible?

Hi Zeek, this post has the TMO with higher aggregation: https://usethinkscript.com/threads/...llator-for-thinkorswim.9413/page-3#post-98402

The study already includes a bunch of label stuff built into it, which might already be what you want. But if you wanted a simpler label like the previous one I posted, you'd just use this code I think:

Code:
AddLabel(yes,"TMO Lower Aggregation", if Mainday > Signalday then color.green else color.red);
AddLabel(yes,"TMO Higher Aggregation", if Mainwk > Signalwk then color.green else color.red);

The study has:
input aggday = AggregationPeriod.DAY;
input aggwk = AggregationPeriod.WEEK;

So you can change each to the desired period.
 
I used this study to modify my momentum bubble indicator. They were previously all white colored.
https://tos.mx/nLN05CS

Here's my current setup:
https://usethinkscript.com/threads/tmo-true-momentum-oscillator-chart-setup-for-thinkorswim.12905/
Code:
#### bubble colors

DefineGlobalColor("blue_cloud", (CreateColor(51, 204, 255)));
DefineGlobalColor("white_cloud", Color.white);

input length = 14;
input calcLength = 5;
input 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);
plot Main = ExpAverage(EMA5, smoothLength);

plot Signal = ExpAverage(Main, smoothLength);
     Main.AssignValueColor(if Main > Signal
                           then (CreateColor(51, 204, 255))
                           else color.white);



################### bubble code

input avg1Type = Averagetype.simple;
input avg2type = Averagetype.simple;
input Avg1Length = 9;
input Avg2Length = 50;

def avg1 = MovingAverage(avg1Type, close, avg1Length);
def avg2 = MovingAverage(avg2Type, close, avg2Length);
def avgup = (avg1 > avg2);

#def AvgPercent = MovingAverage(avg1Type, close, avg1Length)-MovingAverage(avg2Type, close, avg2Length);
# plot percentDiff = (absValue(avgPercent)/movingaverage(avg1type,close,avg1length)) *100;

def Avg12diff = avg1 - avg2;

######################################################################
######################################################################

def yyyyMmDd = getYyyyMmDd();
def session_duration_minutes = (regularTradingEnd(yyyyMmDd) - regularTradingStart(yyyyMmDd)) / AggregationPeriod.MIN;
def interval_size_raw;
def agg  = getAggregationPeriod();
if (agg == AggregationPeriod.DAY) {
    interval_size_raw = session_duration_minutes * 60;
} else if (agg == AggregationPeriod.THREE_DAYS) {
    interval_size_raw = session_duration_minutes * 60 * 3;
} else if (agg == AggregationPeriod.WEEK) {
    interval_size_raw = session_duration_minutes * 60 * 5;
} else if (agg == AggregationPeriod.MONTH or agg == AggregationPeriod.OPT_EXP) {
    interval_size_raw = session_duration_minutes * 60 * 22;
} else if (agg >= AggregationPeriod.MIN) {
    interval_size_raw = agg / AggregationPeriod.MIN;
} else {
    interval_size_raw = agg;
}

##########################################################

def cclose = close(period = agg);
def oopen  = open(period = agg);
def hhigh  = high(period = agg);
def llow   = low(period = agg);
# ########################################################
input smaLength = 40;
def limit = 30;
def AbsHighClose = AbsValue(hhigh - cclose[1]);
def AbsLowClose = AbsValue(llow - cclose[1]);
def AbsCloseOpen = AbsValue(cclose[1] - oopen[1]);
def K = If(AbsHighClose >= AbsLowClose, AbsHighClose, AbsLowClose);
def R = If(AbsHighClose >= AbsLowClose,
        If(AbsHighClose >= (hhigh - llow), AbsHighClose - 0.5 * AbsLowClose + 0.25 * AbsCloseOpen, (hhigh - llow) + 0.25 * AbsCloseOpen),
        If(AbsLowClose >= (hhigh - llow),  AbsLowClose - 0.5 * AbsHighClose + 0.25 * AbsCloseOpen, (hhigh - llow) + 0.25 * AbsCloseOpen));
def nRes = If(R != 0,
            (50 * (((cclose - cclose[1]) + 0.50 * (cclose - oopen) + 0.25 * (cclose[1] - oopen[1])) / R ) * K / limit) + if !IsNaN(nRes[1]) then nRes[1] else 0,
            0 + if !IsNaN(nRes[1]) then nRes[1] else 0);
def ASI = nRes;
def sma = SimpleMovingAvg(ASI,smaLength);

###########################

def momentum = round(ASI);

plot static = momentum;
static.AssignValueColor(color.white);




#AddChartBubble(static, low, round(ASI), Color.white, no);

AddChartBubble(static, low, round(ASI),if Main > Signal then (CreateColor(51, 204, 255)) else color.white, no);

##########################

input barcount = 19;
 
Last edited by a moderator:
I'd like to include a vertical line on the TMO for each market open (9:30 EST) so that I can quickly see each day on it.
 
TMO WatchList
IEf8RM8.png

Ruby:
# ########################################################
# TMO ((T)rue (M)omentum (O)scilator) WatchList Column Only
# Mobius, with modifications by tomsk, 1.1.2020
#with WatchList added by @MerryDay 12/2020
#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.
input showlabels = yes ;
input length = 14;
input calcLength = 5;
input smoothLength = 3;
input tmo_ob =  10;
input tmo_os = -10;

def data = fold i = 0 to length
           with s
           do s + (if close > getValue(open, i)
                   then 1
                   else if close < getValue(open, i)
                        then - 1
                        else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
# ########################################################
#charting and formatting
plot TMO = round(main,0);
AssignBackgroundColor(
if main < tmo_os      then CreateColor(50, 200, 255) else
if main > tmo_ob      then CreateColor(255, 139 ,61) else
if main crosses above tmo_os then CreateColor(0, 0, 255) else
if main crosses below tmo_ob then CreateColor(255, 204, 0) else
if main < signal  then CreateColor(225, 0, 0) else
if main > main[1] then CreateColor(0, 165, 0) else CreateColor(204, 204, 204)) ;
Shared Link: http://tos.mx/6HaRN1a
is it possible to make this watchlist one for 15m and 1h? Cant find anywhere how to modify watchlists
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
410 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top