Login Page - Create Account

Support Board


Date/Time: Wed, 25 Dec 2024 02:01:29 +0000



5m study overlay onto 1m chart - data different for bar-backtest versus sim/live

View Count: 1895

[2015-08-14 02:36:00]
hung4me - Posts: 8
I am overlaying a 5 minute moving average onto a 1 minute chart and using it in ACSIL program. When backtesting, the value stays the same for five 1 minute bars, changes and stays the same for another five 1 minute bars, etc.


When connected to data service however, the 5 minute moving average changes every 1 minute bar. This leads to inconsistent results between backtest and sim test. the below log snippet shows this and also the RSI overlay does the same.

On the overlay study settings, I have "draw zeroes" set to no and Bar Time Matching Method set to nearest match. Also odd is that the 5m subgraphs show like the values only change every 5 minutes but the when I reference the subgraph (screen print attached) in my code like 5nowMA[sc.Index] and log it, the values change every minute. Is there some setting I am unaware of to change this behavior? THANKS IN ADVANCE FOR ANY HELP!

Chart: ESU5 [CB] 1 Min #1 | Study: 2 | 5nowMA, | 2015-08-13 22:12:56 *
Chart: ESU5 [CB] 1 Min #1 | Study: 2 | 2080.132568 | 2015-08-13 22:12:56 *
Chart: ESU5 [CB] 1 Min #1 | Study: 2 | Slow Fast | 2015-08-13 22:12:56 *
Chart: ESU5 [CB] 1 Min #1 | Study: 2 | 58.919930 59.375000 | 2015-08-13 22:12:56 *

Chart: ESU5 [CB] 1 Min #1 | Study: 2 | 22 13 | 2015-08-13 22:13:56 *
Chart: ESU5 [CB] 1 Min #1 | Study: 2 | 5nowMA, | 2015-08-13 22:13:56 *
Chart: ESU5 [CB] 1 Min #1 | Study: 2 | 2080.087158 | 2015-08-13 22:13:56 *
Chart: ESU5 [CB] 1 Min #1 | Study: 2 | Slow Fast | 2015-08-13 22:13:56 *
Chart: ESU5 [CB] 1 Min #1 | Study: 2 | 58.732719 58.064514 | 2015-08-13 22:13:56 *
Date Time Of Last Edit: 2015-08-15 22:41:04
imagesupport case screen print.png / V - Attached On 2015-08-14 02:34:36 UTC - Size: 13.36 KB - 337 views
[2015-08-15 22:42:28]
Sierra Chart Engineering - Posts: 104368
When backtesting, the value stays the same for five 1 minute bars, changes and stays the same for another five 1 minute bars, etc.


To solve this you need to replay both charts at the same time. This is documented here:
http://www.sierrachart.com/index.php?page=doc/doc_Backtesting.php#BackTestingMultipleCharts
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2015-08-17 01:18:17]
hung4me - Posts: 8
The problem is not with replay. Replay works every time. The problem is with live (sim account) data. Also in looking at this, when I log the 5 minute moving average (subgraph#[sc.Index]), it is not even giving accurate results. The value logged is not the same as shows on the tools value window. I have tried this with FreeDLL set to 0 and with it set to 1.
[2015-08-17 01:24:28]
Sierra Chart Engineering - Posts: 104368
Replay works every time. The problem is with live (sim account) data.
OK we think we understand what you are trying to say. You will only have a consistency between real-time updating and Back Testing if you perform a Replay Based Back Test for all charts being referenced. A Bar Based Back test will never be the same for a couple of reasons.

Also in looking at this, when I log the 5 minute moving average (subgraph#[sc.Index]), it is not even giving accurate results. The value logged is not the same as shows on the tools value window.
This is because you are comparing values at different column indexes or the values in the Tool Values window are not up to date. You really should look at the Chart Values window. Otherwise, this is something you have to troubleshoot yourself. It is impossible for us to say exactly what the problem is. Only you can make that determination.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
Date Time Of Last Edit: 2015-08-17 01:27:06
[2015-08-18 01:15:39]
hung4me - Posts: 8
I think this is more than I can explain on the message board. Can you do a webex or other type of call where you can see my message log? If so, can this be done in the evenings? I work my day job 8 - 5 EDT. Thanks.
[2015-08-18 04:18:36]
Sierra Chart Engineering - Posts: 104368
As a matter of policy, we do not provide programming help or automated trading system debugging using remote assistance even for an additional cost.

We can provide you some sample code to output study values at the last array index so you can compare them to the Window >> Chart Values Window.

It is also critical that you read and understand the information in this section here about calculation precedence:
https://www.sierrachart.com/index.php?page=doc/doc_ChartStudies.html#StudyCalculationPrecedence

Take the time to read that section.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2015-08-19 23:12:03]
hung4me - Posts: 8
Thanks for those links - I had never seen them before and very good to know about which studies are calculated in what order.

What I did to simplify things and so you don't have to worry about debugging my code was to create a new custom ACSIL study that only does two things. It populates an array from a 5m moving average overlay study and then logs the values from that array. No trading or other calculations or other studies to complicate things. Looking at the log, I found what is giving me fits and I'm hoping you can explain what does not seem right in my way of thinking. In the log snippet at the bottom of this post, the 5MA array values are from left to right: The index value SC.Index, the array at current index, then array at index minus 1, then minus 2, minus 3 etc.

What I don't understand is how, for example, how the array value at index minus 5 at 18:13 can be different than the minus 4 value at 18:12 because (I think) they point to the same data point at the same moment in time.

index 4096 - 5 = 4091
index 4095 - 4 = 4091

Shouldn't the 5ma array value at index 4091 never change? The way I think about it is like this....

If someone asks me what time the sun came up today and I answered 7:12 AM, then they could ask me the same question 1 day later (i.e. day index minus 1) or the next day (index minus 2) or the next or the next or the next and the answer would always be the same 7:12 AM. As you can see in the log (full file and also the .CPP code is attached), it changes a lot and this is what is causing me problems.

Once a price bar closes, the price should never change. And the formula to calculate a moving average certainly does not change so shouldn't the results remain constant? I understand that as the 5m bar is changing in price that the values at DIFFERENT indexes can be different (e.g. 4096 could be different that 4094 or 4093 because the 5m bar has not closed) but how can the same index have different values? Whatever the 5ma was at 18:11 is what it was. After that point in time the MA can and will change but we can't go back in time and change what was.

Sorry for the long winded and I'm sure redundant post. And this is not a rant - believe me. I love Sierra Chart - it is an awesome tool and I also appreciate the quick answers to my post here. I am sorry I did not take time to explain the issue better. I probably didn't really realize what the issue was. I really just thought I had some setting wrong or that the "Fill blanks with last value" setting was conflicting with something else.

Hope you can help with this - I really need to see non-changing MA values like the back test gives.

Here is the log snippet but it is easier to read in Wordpad


Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | H M | 2015-08-19 18:09:17 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 18 8 | 2015-08-19 18:09:17 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | SC.Index 5MA-cur-idx 5MA-index-1 5MA-index-2 5MA-index-3 5MA-index-4 5MA-index-5 | 2015-08-19 18:09:17 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 4091 0.000000 0.000000 0.000000 0.000000 0.000000 2073.623291 | 2015-08-19 18:09:17 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | H M | 2015-08-19 18:10:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 18 9 | 2015-08-19 18:10:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | SC.Index 5MA-cur-idx 5MA-index-1 5MA-index-2 5MA-index-3 5MA-index-4 5MA-index-5 | 2015-08-19 18:10:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 4092 0.000000 2073.737305 0.000000 0.000000 0.000000 0.000000 | 2015-08-19 18:10:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | H M | 2015-08-19 18:11:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 18 10 | 2015-08-19 18:11:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | SC.Index 5MA-cur-idx 5MA-index-1 5MA-index-2 5MA-index-3 5MA-index-4 5MA-index-5 | 2015-08-19 18:11:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 4093 0.000000 0.000000 2073.691895 0.000000 0.000000 0.000000 | 2015-08-19 18:11:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | H M | 2015-08-19 18:12:05 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 18 11 | 2015-08-19 18:12:05 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | SC.Index 5MA-cur-idx 5MA-index-1 5MA-index-2 5MA-index-3 5MA-index-4 5MA-index-5 | 2015-08-19 18:12:05 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 4094 0.000000 0.000000 0.000000 2073.646240 0.000000 0.000000 | 2015-08-19 18:12:05 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | H M | 2015-08-19 18:13:07 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 18 12 | 2015-08-19 18:13:07 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | SC.Index 5MA-cur-idx 5MA-index-1 5MA-index-2 5MA-index-3 5MA-index-4 5MA-index-5 | 2015-08-19 18:13:07 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 4095 0.000000 0.000000 0.000000 0.000000 2073.691895 0.000000 | 2015-08-19 18:13:07 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | H M | 2015-08-19 18:14:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 18 13 | 2015-08-19 18:14:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | SC.Index 5MA-cur-idx 5MA-index-1 5MA-index-2 5MA-index-3 5MA-index-4 5MA-index-5 | 2015-08-19 18:14:00 *
Chart: ESU5 [CB] 1 Min #1 | Study: 5MA logging for debug | 4096 0.000000 0.000000 0.000000 0.000000 0.000000 2073.737305 | 2015-08-19 18:14:00 *
attachment5ma debug live test 1.rtf - Attached On 2015-08-19 23:07:23 UTC - Size: 3.89 KB - 381 views
attachment5madebug.cpp - Attached On 2015-08-19 23:07:37 UTC - Size: 3.2 KB - 386 views
[2015-08-20 11:42:50]
hung4me - Posts: 8
Another question I forgot to include in the last post. Why are there always zero values in the 5MA array at the current index? Is it there but this something different needing to be done to log this correctly? Thanks!
[2015-11-13 21:04:33]
Sierra Chart Engineering - Posts: 104368
Please have a look at the updated documentation for the Study/Price Overlay study here regarding all of this:
http://www.sierrachart.com/index.php?page=doc/doc_TechnicalStudiesReference.html#s118
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

For the most reliable, advanced, and zero cost futures order routing, *change* to 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