Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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
Can you help answer these questions from other members on NexusFi?
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.