@trouble56 You can refer to this code that @Maya posted here. It combines two different agg for TMO. You may have to adjust the condition (crossing above/below) that you wanted.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
# My version of so called "blackFLAG FTS PLATINUM Ver. 5.0" @Maya
# TMO ((T)rue (M)omentum (O)scillator) With Higher Aggregation
# 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 agg = AggregationPeriod.HOUR;
def o = open(period = agg);
def c = close(period = agg);
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);
# End Code TMO with Higher Aggregation
def bullish = Main crosses above Signal;
def bearish = Main crosses below Signal;
plot bullish_signal = if bullish then 1 else 0;
plot bearish_signal = if bearish then -1 else 0;
This might be a good addition to your chart as I noticed most of the scan result showed volatility squeeze. by the way, it is different than TTM squeeze.In trying to put together a scanner that shows names with all TMO's compressing and heading upwards, With my VERY limited knowledge, this is as far as i've been able to get with it. most versions of the scanner did not return much results but this one I think I might have found a sweet spot... PLEASE if anyone has any ideas to show names where all TMO's are scooping (turning green from the bottom up) together (or consecutively) please feel free to let me know cause i'm actually pretty frustrated with this since either the previous version would show too few results or show the signal had appeared 3-5 days prior... Here's the scanner:
https://tos.mx/eE5Lpm1
#Plots a Volatility Squeeze from a higher aggregation period. The channel plot allows you to quickly see which way price is expanding from the squeeze
###########
Addlabel(1, "Vol Squeeze", color.white);
# Volatility Squeeze: Standard Deviation
# Mobius
# Chat Room Discussion 12.19.2016
# V02.06.16.2018
# Add UI for Higher Aggregation. Added Channel Plot. Added UI controls for Channel Plot, Heritage Points and Label.
input n = 13; #hint n: Length for Standard Deviation calculations
input agg = AggregationPeriod.Fifteen_Min; #hint agg: 2 to 10 times higher than chart agg.
input DisplayChannel = yes;
input HeritagePoints = yes;
input Label = yes;
def h = high(period = agg);
def l = low(period = agg);
def c = close(period = agg);
def x = barNumber();
def nan = double.nan;
def m = Average(c, n);
def SD = stDev(c, n);
def u = m + SD;
def d = m - SD;
def W = (u - d) / m;
def hW = highest(w, n);
def lW = lowest(w, n);
def R = (w - lW) / (hW - lW);
def sq1 = if R crosses below .001
then hl2
else sq1[1];
def sqh = if R crosses below .001
then h
else sqh[1];
def sql = if R crosses below .001
then l
else sql[1];
def sqx = if R crosses below .001
then x
else nan;
plot sq = if HeritagePoints and R <= 0
then sq1
else double.nan;
sq.SetStyle(Curve.Points);
sq.SetLineWeight(3);
sq.SetDefaultColor(Color.Yellow);
sq.HideBubble();
sq.HideTitle();
plot upper = if DisplayChannel and x >= HighestAll(sqx)
then HighestAll(if isNaN(c[-1])
then sqh
else nan)
else nan;
upper.SetStyle(Curve.Long_Dash);
upper.SetLineWeight(2);
upper.SetDefaultColor(Color.Green);
upper.HideBubble();
upper.HideTitle();
plot lower = if DisplayChannel and x >= HighestAll(sqx)
then HighestAll(if isNaN(c[-1])
then sql
else nan)
else nan;
lower.SetStyle(Curve.Long_Dash);
lower.SetLineWeight(2);
lower.SetDefaultColor(Color.Red);
lower.HideBubble();
lower.HideTitle();
addCloud(lower, upper, color.light_orange, color.light_orange);
addLabel(Label, if R > .9
then "Vol Expanding: " + R
else if R < .01
then "Squeeze: " + R
else "Drift: " + R,
if R < .01
then color.red
else if R > .9
then color.green
else color.white);
# End Code
@BenTen Is there a way I can add alert to a strategy? Thanks!@scalper81 Correct, that is not repainting but rather just the fluctuation when waiting for the higher timeframe candle to close.
Both Studies and Strategies use Alert()'s the same way... The main difference between Studies and Strategies is that Strategies can use AddOrder() function calls to generate P/L reports...@BenTen Is there a way I can add alert to a strategy? Thanks!
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Archived: TMO True Momentum Oscillator | Indicators | 346 | ||
TMO True Momentum Oscillator For ThinkOrSwim | Indicators | 128 |
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.