Calculate EMA using SV's/History lists
Hi. Was advised by support to post this request here. As an exercise (maybe in futility but should be fun to try anyway
) I would like to be able to calculate the EMA (like the one you can add to charts) using SV's and/or history lists (variable periods) for use in horse racing (back,lay or LTP-not fussed.) I have had a go myself but can't seem to get it right. Any help to create a baf appreciated. Cheers 
- ShaunWhite
- Posts: 10604
- Joined: Sat Sep 03, 2016 3:42 am
EMA = Closing price x multiplier + EMA (previous day) x (1-multiplier)
So, the multiplier can be a constant or a simple calc, it's just
[2 ÷ (number of observations + 1)]
Then at the required frequency .....
EMA = price x multiplier + EMAprev x (1-multiplier)
EMAprev = EMA
..and repeat
The calc only needs to remember the prev EMA not a whole history. The shorter the number of observations, the larger the multiplier, and that gives more weight to the current price (the price x multiplier part) than the previous EMA (the EMAprev x (1-multiplier) part). Long observations, smaller muliplier, opposite effect.
You'll need to translate that into Guardianese. That part is beyond my pay grade
Hope it helps.
So, the multiplier can be a constant or a simple calc, it's just
[2 ÷ (number of observations + 1)]
Then at the required frequency .....
EMA = price x multiplier + EMAprev x (1-multiplier)
EMAprev = EMA
..and repeat
The calc only needs to remember the prev EMA not a whole history. The shorter the number of observations, the larger the multiplier, and that gives more weight to the current price (the price x multiplier part) than the previous EMA (the EMAprev x (1-multiplier) part). Long observations, smaller muliplier, opposite effect.
You'll need to translate that into Guardianese. That part is beyond my pay grade
Last edited by ShaunWhite on Fri Jan 27, 2023 1:57 am, edited 1 time in total.
