Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 11:37:28 +0000



SMA/EMA calculation explanation for different timeframe bars.

View Count: 101

[2024-04-30 03:47:06]
beanthehacker - Posts: 28
Hello,

I have SMA/EMA on a 1 minute chart. I use the Study/Price Overlay to add those to my 1 second chart, but let me get to that point later below. What I want to know first is how these are calculated, example:

For 6 min EMA, if time is say 08:35:35 then will 6 min EMA be calculated using data from 08:29:35 till 08:35:35, or will it be 5 mins from 08:30-08:35 and 35 seconds of the current minute?


Coming to the second part, this calculation is important because when I backtest using bar based backtest where there's no option to link the charts on replays, then the EMA values are incorrect since they're rounded off from the minute chart and not constantly changing like it would in live trading.


Thank you for your help.
[2024-04-30 15:12:09]
John - SC Support - Posts: 31704
You define a "Length" not a time. So you are defining the numbers of bars that are used. If this is set to 6, then it is using 6 bars to define the moving average. As such, whatever you are using as the Input to the moving average is going to be taken from those 6 bars. The most recent bar is going to be whatever the value is at any given time - keep in mind the bar updates at the "Chart Update Interval in Milliseconds".
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2024-05-01 01:40:39]
beanthehacker - Posts: 28
Thanks John. I'm using the EMA study on 1 min chart, and overlaying it on the 1s second chart. Now for the 1s chart when I go to a timestamp earlier in the day, that second has the 'rounded off' value for that minute not the value that was there in real-time when that minute's bar was open. I can confirm that when I replay.

Example using above timestamps: 08:35:35 in real-time or during replay has 6 EMA as 5130 (for example). But at the end of the day when I go that timestamp it is rounded off to what the 08:35-36th minute ended up with which would be 5130.5 or something.

Q: Is there a way to capture the real-time values either on the chart or using some other technique/study? Thank you.
[2024-05-01 14:38:45]
John - SC Support - Posts: 31704
Q: Is there a way to capture the real-time values either on the chart or using some other technique/study? Thank you.

No, there is not a way to do this in the way you are thinking. When you overlay a bar, it is overlaying the information for that bar as it is at that time.

The only way to do what you are wanting would be to add the EMA to the 1 second chart and set the length to be what you are wanting (i.e. if you were using a length of 6 on the 1 minute chart, then you would need to set the length to 360 for a 1 second chart (6 bars x 60 seconds per bar = 360).
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account