Inverted EMA For ThinkOrSwim

halcyonguy

Moderator - Expert
VIP
Lifetime
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:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Wow. That was fast. Thank you so much. I didn't know how complex it was going to be. It works well. I added 'displace' so I could create the projections. See the images below.


Here's an example of the projection overlaid on to Friday (yesterday). You'll see that if you followed the inversion, you would have an idea of the price movement for the day.


The image below will show you where I got the projection from. You're looking at a 5 day intraday (5 minute) chart. I am using a 4 day cycle which includes weekends in the count. For this example, the day was Friday, so I went back 4 days to Monday.


So if Today is Monday and I want to get an idea of the price movement, I count 4 days back and that takes me to Thursday. Using the exponential moving average with a length of 5, I move the EMA forward (displace) to Monday, I'd get a projection. I've found out over the years that projections based on this cycle INVERTS. So using the inversion you created, I can see whether "Monday's price movement' would follow the normal cycle or the inversion. Depending on which time frame i use ( 5, 15 or 60 min., bars) I would just count the number of bars per day and use that to enter the correct displacement. I created an excel chart for this.
Anyway, thank you so much for your help. You're awesome.,
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
242 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

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.

How do I get started?

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.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top