I use an Exponential Moving Average to help me create price projections by displacing them. This allows me to 'see a possible path' that the price can take moving forward. See image below (BA on a 15 minute chart). Is there a way to plot the 'inversion' of the displaced EMA? Since I am not able to write thinkscript code, the way I do it is by opening another chart, adding a 'negative sign' before the ticker symbol and it gives me the inversion of the whole chart. I am hoping there's a simpler way of doing it. Any help would be greatly appreciated.
this will plot a normal EMA signal and an inverted version of it.
this is complex. i used highestall, lowestall, to find the vertical limits on the chart.
it calculates the distance the EMA is above the lowest level, then subtracts that number from the highest level, and plots the inverted version.
Code:
# invert an EMA signal
# halcyonguy 2/2022
def na = double.nan;
def h = highestall(high);
def l = lowestall(low);
input avg_type = AverageType.Exponential;
input avg_len = 20;
def ma1 = MovingAverage(avg_type, close, avg_len);
input show_ma1 = yes;
plot z1 = if show_ma1 then ma1 else na;
z1.setdefaultcolor(color.cyan);
def lowdiff = ma1 - l;
def ma1_inv = h - lowdiff;
input show_inverted_ma1 = yes;
plot z2 = if show_inverted_ma1 then ma1_inv else na;
z2.setdefaultcolor(color.yellow);
z2.SetStyle(Curve.MEDIUM_DASH);
addlabel(1,"original",color.cyan);
addlabel(1,"inverted",color.yellow);
#
Last edited: