Support Board
Date/Time: Wed, 25 Dec 2024 13:58:22 +0000
Post From: 5m study overlay onto 1m chart - data different for bar-backtest versus sim/live
[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 * |
5ma debug live test 1.rtf - Attached On 2015-08-19 23:07:23 UTC - Size: 3.89 KB - 382 views 5madebug.cpp - Attached On 2015-08-19 23:07:37 UTC - Size: 3.2 KB - 387 views |