##shared_TMO_wHigherAgg_SAIMOD3_Day_Wk
#TMO True Momentum Oscillator with Higher Aggregation _Mobius
#Tuesday, May 15, 2018 12:36 PM
## OneNote Archive Name: TMO True Momentum Oscillator with Higher Aggregation _Mobius
## Archive Section: Momentum
## Suggested Tos Name: TrueMomentumOscillator_w_HigherAggregation_Mobius
## Archive Date: 5.15.2018
## Archive Notes:
## 08:43 Mobius: Well give it a few days to get altered, muched, distorted and twisted. Then when it get back to being used as intended someone will start making money with it.
## 08:45 Mobius: Oh and in my view - It's highest and best use is as designed with a secondary aggregation plotted either on it or with it around 5 to 10 time higher.
## "##" indicates an addition or adjustment by the OneNote Archivist
## Original Code Follows
# TMO ((T)rue (M)omentum (O)scillator) With Higher Aggregation
# Mobius
# V01.05.2018
# 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
#EvilSurgeon 5/16/22
#Combined Weekly and Daily into on script
#Tweeked Rising/Falling Def
#Added Breakouts
#Added arrows for crossovers
#Changed Lables per Preference
#Changed Colors Per Preference
#Combined all headers
#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.
#Original Label color assignment:
#Red =Falling.. main < signal
#Orange =Trend is maxing out.. main > overbought
#Gray =No trend, probable reversal..
#Cyan =Pre-trend.. main > signal and main < oversold
#Green =Trend is rising.. main > signal, main > oversold, main is rising, main < overbought
#BLUE =BEGINNING TO TREND.. main > signal and main is crossing above oversold
#Yellow =END OF TREND.. main crossing below overbought
#declare lower;
input length = 14;
input calcLength = 5;
input smoothLength = 3;
input aggday = AggregationPeriod.DAY;
input aggwk = AggregationPeriod.WEEK;
def oday = open(period = aggday);
def cday = close(period = aggday);
def dataday = fold i = 0 to length
with s
do s + (if cday > GetValue(oday, i)
then 1
else if cday < GetValue(oday, i)
then - 1
else 0);
def EMA5day = ExpAverage(dataday, calcLength);
plot Mainday = ExpAverage(EMA5day, smoothLength);
mainday.SetLineWeight(2);
#Main.AssignValueColor(if Main > Signal
# then Color.GREEN
# else Color.RED);
plot Signalday = ExpAverage(Mainday, smoothLength);
signalday.SetLineWeight(2);
#Signal.AssignValueColor(if Main > Signal
#then Color.GREEN
#else Color.RED);
Signalday.HideBubble();
Signalday.HideTitle();
#AddCloud(Main, Signal, Color.LIGHT_GREEN, Color.RED);
def owk = open(period = aggwk);
def cwk = close(period = aggwk);
def datawk = fold iwk = 0 to length
with swk
do swk + (if cwk > GetValue(owk, iwk)
then 1
else if cwk < GetValue(owk, iwk)
then - 1
else 0);
def EMA5wk = ExpAverage(datawk, calcLength);
plot Mainwk = ExpAverage(EMA5wk, smoothLength);
mainwk.SetLineWeight(2);
#Main.AssignValueColor(if Main > Signal
# then Color.GREEN
# else Color.RED);
plot Signalwk = ExpAverage(Mainwk, smoothLength);
signalwk.SetLineWeight(2);
#Signal.AssignValueColor(if Main > Signal
#then Color.GREEN
#else Color.RED);
#Signal.HideBubble();
#Signal.HideTitle();
#AddCloud(Main, Signal, Color.LIGHT_GREEN, Color.RED);
plot zero = if IsNan(cday) then Double.NaN else 0;
zero.SetDefaultColor(Color.GRAY);
zero.HideBubble();
zero.HideTitle();
plot ob = if IsNan(cday) then Double.NaN else 10;
ob.SetDefaultColor(Color.GRAY);
ob.HideBubble();
ob.HideTitle();
plot os = if IsNan(cday) then Double.NaN else -10;
os.SetDefaultColor(Color.GRAY);
os.HideBubble();
os.HideTitle();
AddCloud(ob, length, CreateColor(50, 205, 50), CreateColor(50, 205, 50), yes);
AddCloud(-length, os,CreateColor ( 240,128,128 ),CreateColor ( 240,128,128 ), yes);
#charting and formatting
DefineGlobalColor("pretrend", CreateColor(0, 255, 127));
DefineGlobalColor("TrendBEGIN", Color.DARK_GREEN);
DefineGlobalColor("TrendBrkOutUp", CreateColor( 34, 139, 34 ) );
DefineGlobalColor("rising", CreateColor(60, 179, 113));
DefineGlobalColor("maxxed", Color.DARK_ORANGE);
DefineGlobalColor("TrendEnd", Color.DARK_RED);
DefineGlobalColor("TrendBrkoutDwn", Color.RED);
DefineGlobalColor("falling", color.downtick); #CreateColor(255, 215, 0));
DefineGlobalColor("neutral", Color.YELLOW);
AddLabel(yes, "TMO Trnd Day", Color.BLUE);
AddLabel( mainday < os , "PreTrnd" , GlobalColor("pretrend") );
AddLabel( mainday > ob , "TrndMax" , GlobalColor("maxxed") );
AddLabel( mainday crosses above os , "BeginTrnd" , GlobalColor("TrendBEGIN") );
AddLabel( mainday crosses below ob , "TrndEnd" , GlobalColor("TrendEnd") );
AddLabel( mainday < signalday , "Bearish", GlobalColor("falling") );
AddLabel( mainday >= signalday, "Bullish" , GlobalColor("rising") );
AddLabel( mainday crosses above signalday , "Trend BrkOut Up" , GlobalColor("TrendBrkOutUp") );
AddLabel( mainday crosses below signalday , "Trend Brkout Dwn" , GlobalColor("TrendBrkoutDwn") );
AddLabel( mainday < mainday[1] , "TrndDwn" , GlobalColor("falling") );
AddLabel( mainday >= mainday[1] , "TrndUp" , GlobalColor("rising") );
mainday.AssignValueColor(
if mainday < os then GlobalColor("pretrend") else
if mainday > ob then GlobalColor("maxxed") else
if mainday crosses above os then GlobalColor("TrendBEGIN") else
if mainday crosses below ob then GlobalColor("TrendEND") else
if mainday crosses above signalday then GlobalColor("TrendBrkOutUp") else
if mainday crosses below signalday then GlobalColor("TrendBrkoutDwn") else
if mainday < signalday then GlobalColor("falling") else
if mainday >= signalday then GlobalColor("rising") else
if mainday < mainday[1] then GlobalColor("falling") else
if mainday >= mainday[1] then GlobalColor("rising") else
GlobalColor("neutral")) ;
signalday.AssignValueColor(
if mainday < os then GlobalColor("pretrend") else
if mainday > ob then GlobalColor("maxxed") else
if mainday crosses above os then GlobalColor("TrendBEGIN") else
if mainday crosses below ob then GlobalColor("TrendEND") else
if mainday crosses above signalday then GlobalColor("TrendBrkOutUp") else
if mainday crosses below signalday then GlobalColor("TrendBrkoutDwn") else
if mainday < signalday then GlobalColor("falling") else
if mainday >= signalday then GlobalColor("rising") else
if mainday < mainday[1] then GlobalColor("falling") else
if mainday >= mainday[1] then GlobalColor("rising") else
GlobalColor("neutral")) ;
AddCloud(if mainday crosses below ob then mainday else double.nan, if mainday crosses below ob then signalday else double.nan, GlobalColor("TrendEND"), GlobalColor("TrendEND"));
AddCloud(if mainday crosses above os then mainday else double.nan, if mainday crosses above os then signalday else double.nan, GlobalColor("TrendBEGIN"), GlobalColor("TrendBEGIN"));AddCloud(if mainday > ob then mainday else double .nan , if signalday > ob then signalday else double.nan, GlobalColor("maxxed"), GlobalColor("maxxed"));
AddCloud(mainday , signalday, GlobalColor("rising"), GlobalColor("falling"));
AddCloud(if mainday < os then mainday else double.nan, if mainday < os then signalday else double.nan, GlobalColor("pretrend"), GlobalColor("pretrend"));
plot arrow = if mainday crosses above os then mainday else Double.NaN;
arrow.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
arrow.SetDefaultColor(Color.DARK_GREEN);
arrow.SetLineWeight(4);
plot arrow2 = if mainday crosses below ob then mainday else Double.NaN;
arrow2.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrow2.SetDefaultColor(Color.DARK_RED);
arrow2.SetLineWeight(4);
plot arrow3_1 = if mainday crosses above signalday then mainday else double.nan;
arrow3_1.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
arrow3_1.SetDefaultColor(Color.GREEN);
arrow3_1.SetLineWeight(4);
plot arrow4 = if mainday crosses below signalday then mainday else Double.NaN;
arrow4.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrow4.SetDefaultColor(Color.RED);
arrow4.SetLineWeight(4);
AddLabel(yes, " ", color.black);
AddLabel(yes, "TMO Trnd Week", Color.BLUE);
AddLabel( mainwk < os , "PreTrnd" , GlobalColor("pretrend") );
AddLabel( mainwk > ob , "TrndMax" , GlobalColor("maxxed") );
AddLabel( mainwk crosses above os , "BeginTrnd" , GlobalColor("TrendBEGIN") );
AddLabel( mainwk crosses below ob , "TrndEnd" , GlobalColor("TrendEnd") );
AddLabel( mainwk < signalwk , "Bearish", GlobalColor("falling") );
AddLabel( mainwk >= signalwk, "Bullish" , GlobalColor("rising") );
AddLabel( mainwk crosses above signalwk , "Trend BrkOut Up" , GlobalColor("TrendBrkOutUp") );
AddLabel( mainwk crosses below signalwk , "Trend Brkout Dwn" , GlobalColor("TrendBrkoutDwn") );
AddLabel( mainwk < mainwk[1] , "TrndDwn" , GlobalColor("falling") );
AddLabel( mainwk >= mainwk[1] , "TrndUp" , GlobalColor("rising") );
mainwk.AssignValueColor(
if mainwk < os then GlobalColor("pretrend") else
if mainwk > ob then GlobalColor("maxxed") else
if mainwk crosses above os then GlobalColor("TrendBEGIN") else
if mainwk crosses below ob then GlobalColor("TrendEND") else
if mainwk crosses above signalwk then GlobalColor("TrendBrkOutUp") else
if mainwk crosses below signalwk then GlobalColor("TrendBrkoutDwn") else
if mainwk < signalwk then GlobalColor("falling") else
if mainwk >= signalwk then GlobalColor("rising") else
if mainwk < mainwk[1] then GlobalColor("falling") else
if mainwk >= mainwk[1] then GlobalColor("rising") else
GlobalColor("neutral")) ;
signalwk.AssignValueColor(
if mainwk < os then GlobalColor("pretrend") else
if mainwk > ob then GlobalColor("maxxed") else
if mainwk crosses above os then GlobalColor("TrendBEGIN") else
if mainwk crosses below ob then GlobalColor("TrendEND") else
if mainwk crosses above signalwk then GlobalColor("TrendBrkOutUp") else
if mainwk crosses below signalwk then GlobalColor("TrendBrkoutDwn") else
if mainwk < signalwk then GlobalColor("falling") else
if mainwk >= signalwk then GlobalColor("rising") else
if mainwk < mainwk[1] then GlobalColor("falling") else
if mainwk >= mainwk[1] then GlobalColor("rising") else
GlobalColor("neutral")) ;
AddCloud(if mainwk crosses below ob then mainwk else double.nan, if mainwk crosses below ob then signalwk else double.nan, GlobalColor("TrendEND"), GlobalColor("TrendEND"));
AddCloud(if mainwk crosses above os then mainwk else double.nan, if mainwk crosses above os then signalwk else double.nan, GlobalColor("TrendBEGIN"), GlobalColor("TrendBEGIN"));
AddCloud(if mainwk > ob then mainwk else double .nan , if signalwk > ob then signalwk else double.nan, GlobalColor("maxxed"), GlobalColor("maxxed"));
AddCloud(mainwk , signalwk, GlobalColor("rising"), GlobalColor("falling"));
AddCloud(if mainwk < os then mainwk else double.nan, if mainwk < os then signalwk else double.nan, GlobalColor("pretrend"), GlobalColor("pretrend"));
plot arrowwk = if mainwk crosses above os then mainwk else Double.NaN;
arrowwk.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
arrowwk.SetDefaultColor(CreateColor(60, 179, 113));
arrowwk.SetLineWeight(4);
plot arrow2wk = if mainwk crosses below ob then mainwk else Double.NaN;
arrow2wk.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrow2wk.SetDefaultColor(Color.downtick);
arrow2wk.SetLineWeight(4);
plot arrow3_1wk = if mainwk crosses above signalwk then mainwk else double.nan;
arrow3_1wk.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
arrow3_1wk.SetDefaultColor(CreateColor(50, 205, 50));
arrow3_1wk.SetLineWeight(4);
plot arrow4wk = if mainwk crosses below signalwk then mainwk else Double.NaN;
arrow4wk.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
arrow4wk.SetDefaultColor(CreateColor(255, 215, 0));
arrow4wk.SetLineWeight(4);
# End Code