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.I still get Exactly one plot expected error. The formula won't compile. Any help will be appreciated.
These are the Top 20 Divergence Indicators on the ForumTrue 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
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 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 timeTMO ((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 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
# 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 ;
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 ;
put this at the bottom of your scan study:how would you word this for only trend end and trend begin candles?
##***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
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
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);
AddLabel(yes,"TMO", if Main > Signal then color.green else color.red);
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());
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;
}
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?
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);
#### 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;
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.
is it possible to make this watchlist one for 15m and 1h? Cant find anywhere how to modify watchlistsTMO WatchList
Shared Link: http://tos.mx/6HaRN1aRuby:# ######################################################## # 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)) ;
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Archived: TMO True Momentum Oscillator | Indicators | 346 | ||
TMO with Higher Agg_Mobius @ TSL | Indicators | 204 | ||
C | True Strength Index Indicator for ThinkorSwim | Indicators | 34 | |
D | Average True Range (ATR) Implied Move for ThinkorSwim | Indicators | 5 | |
T | Repaints Multi-Time Frame True Momentum Oscillator (MTF) for ThinkorSwim | Indicators | 149 |
Start a new thread and receive assistance from our community.
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.
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.