ShiftedMA and ShiftDelay throw exception using negative periods
Author: gtg907g
Creation Date: 5/18/2019 5:35 PM
profile picture

gtg907g

#1
The "ShiftedMA" and "ShiftDelay" indicators in the "Community Indicators" are throwing exceptions when I attempt to shift and EMA using negative integers.

For example - if I take the "ShiftedMA" and apply it to a 3 period EMA and select "-3" for the "Shift(delay)" - it throws an exception. Same happens when I apply the "ShiftDelay" to the "EMA" indicator using negative integers.

At the risk of sounding stupid - I don't think that should happen? In this case, I'm interested in actually shifting that moving average to the LEFT, not the RIGHT.
profile picture

Eugene

#2
There is hardly a practical purpose in shifting a moving average to the left as this creates a peeking effect. The ShiftedMA and ShiftDelay work with positive values only. Doing otherwise causes an index out of bounds condition which is unhandled. The online guide suggests that the indicator only shifts to the right, and if you're after doing the other way round it's possible to do in code - just care to not exceed Bars.Count-1 in looping bar by bar.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).