TMO Indicator w/ Candlesticks painting

BULLFIZZ

Member
Platform
  1. Thinkorswim
@barbaros Can you please edit this TMO lable indicator to match it with candlessticks color? Here's the code
Thank you very much.


# ########################################################
# TMO ((T)rue (M)omentum (O)scilator)
# Mobius, with modifications by tomsk, 1.1.2020
#with Labels and Candle Painting 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);
#DefineGlobalColor("pretrend", CreateColor(50, 200, 255)) ;
#DefineGlobalColor("TrendBEGIN", CreateColor(0, 0, 255)) ;
#DefineGlobalColor("rising", CreateColor(0, 165, 0)) ;
#DefineGlobalColor("maxxed", CreateColor(255, 139 ,61)) ;
#DefineGlobalColor("TrendEnd", CreateColor(255, 204, 0)) ;
#DefineGlobalColor("falling", CreateColor(225, 0, 0)) ;
#DefineGlobalColor("neutral", CreateColor(204, 204, 204)) ;
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)) ;
 

barbaros

Administrator
Staff member
The only color assignment in the script is for background color. Are you looking to change it to candlestick color? Is that what you meant?
 

barbaros

Administrator
Staff member
Exactly, i want the candles color to align when label changes colors
Sounds good. That’s a very small change.

Code:
# ########################################################
# TMO ((T)rue (M)omentum (O)scilator)
# Mobius, with modifications by tomsk, 1.1.2020
#with Labels and Candle Painting 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);
#DefineGlobalColor("pretrend", CreateColor(50, 200, 255)) ;
#DefineGlobalColor("TrendBEGIN", CreateColor(0, 0, 255)) ;
#DefineGlobalColor("rising", CreateColor(0, 165, 0)) ;
#DefineGlobalColor("maxxed", CreateColor(255, 139 ,61)) ;
#DefineGlobalColor("TrendEnd", CreateColor(255, 204, 0)) ;
#DefineGlobalColor("falling", CreateColor(225, 0, 0)) ;
#DefineGlobalColor("neutral", CreateColor(204, 204, 204)) ;
AssignPriceColor(
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)) ;
 
Top