# filename: MR__EZ_TMO_MTF_Fisher_3Agg_
# source: https://usethinkscript.com/d/91-tmo-with-higher-agg-mobius-tsl
# 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, trend reversals and divergence than momentum oscillators using price.
declare lower;
input length = 10; # default -> 14;
def calcLength = 5;
def smoothLength = 3;
input agg = AggregationPeriod.FIVE_MIN;
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);
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);
Main.SetLineWeight(3);
Signal.SetLineWeight(3);
Signal.HideBubble();
Signal.HideTitle();
# JQ_FisherTransform_wLabels v02
# assistance provided by AlphaInvestor, amalia, randyr and nube
# v02 9.23.2018 JQ added arrows
input Fisherprice = hl2;
input FisherLength = 10;
input TriggerLineOffset = 1; # Ehler's value of choice is 1
input TriggerLine_Color_Choice = {"magenta", "cyan", "pink", default "gray", "Mustard", "red", "green", "dark_gray", "Pale Yellow", "white"};
input deBug = no;
def maxHigh = Highest(Fisherprice, FisherLength);
def minLow = Lowest(Fisherprice, FisherLength);
def range = maxHigh - minLow;
def value = if IsNaN(Fisherprice)
then Double.NaN
else if IsNaN(range)
then value[1]
else if range == 0
then 0
else 0.66 * ((Fisherprice - minLow) / range - 0.5) + 0.67 * value[1];
def truncValue = if value > 0.99 then 0.999 else if value < -0.99 then -0.999 else value;
def fish = 0.5 * (Log((1 + truncValue) / (1 - truncValue)) + fish[1]);
def FTOneBarBack = fish[TriggerLineOffset];
def FT = fish;
plot FisherBullCross = if FT crosses above FTOneBarBack then lowestall(Main) else Double.NaN;
FisherBullCross.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
FisherBullCross.SetDefaultColor(Color.UPTICK);
plot FisherBearCross = if FT crosses below FTOneBarBack then highestall(Main) else Double.NaN;
FisherBearCross.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
FisherBearCross.SetDefaultColor(Color.DOWNTICK);
input length2 = 10; # default -> 14;
def calcLength2 = 5;
def smoothLength2 = 3;
input agg2 = AggregationPeriod.FIFTEEN_MIN;
def o2 = open(period = agg2);
def c2 = close(period = agg2);
def data2 = fold i2 = 0 to length2
with s2
do s2 + (if c2 > getValue(o2, i2)
then 1
else if c2 < getValue(o2, i2)
then - 1
else 0);
def EMA52 = ExpAverage(data2, calcLength2);
plot Main2 = ExpAverage(EMA52, smoothLength2);
plot Signal2 = ExpAverage(Main2, smoothLength2);
Main2.AssignValueColor(if Main2 > Signal2
then color.UPTICK
else color.DOWNTICK);
Signal2.AssignValueColor(if Main2 > Signal2
then color.UPTICK
else color.DOWNTICK);
Signal2.HideBubble();
Signal2.HideTitle();
input length3 = 10; # default -> 14;
def calcLength3 = 5;
def smoothLength3 = 3;
input agg3 = AggregationPeriod.THIRTY_MIN;
def o3 = open(period = agg3);
def c3 = close(period = agg3);
def data3 = fold i3 = 0 to length3
with s3
do s3 + (if c3 > getValue(o3, i3)
then 1
else if c3 < getValue(o3, i3)
then - 1
else 0);
def EMA53 = ExpAverage(data3, calcLength3);
plot Main3 = ExpAverage(EMA53, smoothLength3);
plot Signal3 = ExpAverage(Main3, smoothLength3);
Main3.AssignValueColor(if Main3 > Signal3
then CreateColor(0, 125, 0) #Green
else CreateColor(125, 0, 0)); #Red;
Signal3.AssignValueColor(if Main3 > Signal3
then CreateColor(0, 125, 0) #Green
else CreateColor(125, 0, 0)); #Red
Signal3.HideBubble();
Signal3.HideTitle();
addCloud(Main, Signal, color.GREEN, color.RED);
addCloud(Main2, Signal2, color.UPTICK, color.DOWNTICK);
addCloud(Main3, Signal3, color.DARK_GREEN, color.DARK_RED);
plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.ORANGE);
ZeroLine.HideBubble();
ZeroLine.HideTitle();
plot ob = if isNaN(c) then double.nan else round(length * .7);
ob.SetDefaultColor(Color.dark_red);
ob.HideBubble();
ob.HideTitle();
plot os = if isNaN(c) then double.nan else -round(length * .7);
os.SetDefaultColor(Color.dark_green);
os.HideBubble();
os.HideTitle();
addCloud(ob, length, color.dark_red, color.dark_red, no);
addCloud(-length, os, color.dark_green, color.dark_green);