NexusFi: Find Your Edge


Home Menu

 





Average and Max Distance from EMA


Discussion in ThinkOrSwim

Updated
    1. trending_up 3,384 views
    2. thumb_up 0 thanks given
    3. group 4 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

Average and Max Distance from EMA

  #1 (permalink)
konl
jerusalem israel
 
Posts: 5 since Jul 2017
Thanks Given: 0
Thanks Received: 0

I stuck with a problem and would appreciate getting a direction -
Want to plot (EMA8 + average price distance from EMA8 last year).
The same goes for (EMA8 + maximum distance from the EMA last year)
The main problem I encountered was to find the average distance in the past year and the maximum distance.
Again, I apologize for the digging but it's pretty stuck here

Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Cheap historycal L1 data for stocks
Stocks and ETFs
MC PL editor upgrade
MultiCharts
ZombieSqueeze
Platforms and Indicators
REcommedations for programming help
Sierra Chart
How to apply profiles
Traders Hideout
 
  #2 (permalink)
 
DavidBodhi's Avatar
 DavidBodhi 
Milwaukee, WI, USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Equities
Posts: 209 since Oct 2014
Thanks Given: 23
Thanks Received: 207


konl View Post
I stuck with a problem and would appreciate getting a direction -
Want to plot (EMA8 + average price distance from EMA8 last year).
The same goes for (EMA8 + maximum distance from the EMA last year)
The main problem I encountered was to find the average distance in the past year and the maximum distance.
Again, I apologize for the digging but it's pretty stuck here

You'd have to custom code this, I think. I don't recall anyone mentioning something that would do that for you 'out of the box'.

For the maximum distance, assuming you don't care whether price is above or below the EMA, you'd want to take the value of each and subtract them, then get the absolute value, Math.Abs(), store that in a variable and replace the value any time the current value is greater than what's already stored in the variable.

Something like this:
Diff = Math.Abs(EMA8 - Price)
if (Diff > Variable)
Variable = Diff

Then run that over the past year's historical price bars. The end value for Variable ought to be the maximum distance price was from the EMA over the year. Then you'll need to plot the value.

The average distance, again assuming you don't care which is higher, would be something like:
NewVariable = SMA(Diff)[365]
Meaning, plot some variable making it equal to a simple moving average of the absolute value of the difference between the EMA and price, making the period of the moving average = 1 year.

I'm not a master programmer and just sort of threw this together, so I might be making some dumb mistakes, but I think coding similar to this, conceptually, will get you what you want.

Follow me on Twitter Reply With Quote
  #3 (permalink)
konl
jerusalem israel
 
Posts: 5 since Jul 2017
Thanks Given: 0
Thanks Received: 0



DavidBodhi View Post
You'd have to custom code this, I think. I don't recall anyone mentioning something that would do that for you 'out of the box'.

For the maximum distance, assuming you don't care whether price is above or below the EMA, you'd want to take the value of each and subtract them, then get the absolute value, Math.Abs(), store that in a variable and replace the value any time the current value is greater than what's already stored in the variable.

Something like this:
Diff = Math.Abs(EMA8 - Price)
if (Diff > Variable)
Variable = Diff

Then run that over the past year's historical price bars. The end value for Variable ought to be the maximum distance price was from the EMA over the year. Then you'll need to plot the value.

The average distance, again assuming you don't care which is higher, would be something like:
NewVariable = SMA(Diff)[365]
Meaning, plot some variable making it equal to a simple moving average of the absolute value of the difference between the EMA and price, making the period of the moving average = 1 year.

I'm not a master programmer and just sort of threw this together, so I might be making some dumb mistakes, but I think coding similar to this, conceptually, will get you what you want.

Thank you for replay

Reply With Quote
  #4 (permalink)
 jeffro 
San Diego, CA/United States
 
Experience: Intermediate
Platform: TOS
Trading: ES, CL, 6A
Posts: 17 since Apr 2015
Thanks Given: 2
Thanks Received: 11

You'd need to define at what scale, time or tick over the past year. But this can be done.

Reply With Quote




Last Updated on July 10, 2018


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts