Support Board
Date/Time: Tue, 25 Feb 2025 20:39:46 +0000
Post From: Inconsistent data from VolumeByPrice study when back-testing
[2021-04-22 09:23:42] |
Ernie Doo - Posts: 46 |
I think my problem comes exactly from what you mentioned last. I think you are spot on!! One thing that has come to mind, is that there certainly will be inconsistencies with the creation of Volume Profiles based upon the visible bars with varying back tests speeds.
After a lot of testing and debugging I believe I have narrowed it down. I think that during replay at high speeds the Volume By Price study does not finish "Drawing or plotting" the profile at the moment I call sc.GetVolumeAtPriceDataForStudyProfile and sc.GetNumPriceLevelsForStudyProfile. This is of course an assumption because I do not know internally how the VolumeByPrice study exactly works. I now found out that the Volume does not vary (as I said before and as I explain below) and is actually very accurate. However, the Price Levels value varies very strongly. For example, I tested on S&P, in a Minute Chart, exactly at 2021/01/07 16:43 when that bar opened and in one test I had 161 price levels but in the next test only 73. Just do a quick test. It does not require a lot of debugging at all. Test twice at high speeds and/or max speed. Read out the Price Levels at any time you choose. You will get big different values almost every time (more than 90% of the time if not more). Please, just have a look and tell me what you think. Just to clear things up I am answering your queries here below: We have no idea what your code is doing and how you are coming to this conclusion.
I wrote a simple code just to test this. Every time sc.UpdateStartIndex changes (ie. every new bar) I check 10 ticks up and 10 ticks down from this new bar's OPEN and search for the lowest volumes and save them with their matching prices. To do this I search through sc.GetVolumeAtPriceDataForStudyProfile using the value I get from sc.GetNumPriceLevelsForStudyProfile as limit until I find this bar's OPEN (sc.BaseData[SC_OPEN][sc.UpdateStartIndex]). Once I found it I just check 10 ticks up and down. I then print these values out into a file. So, I can debug or just look at my file after the test. You are completely right about this. We do not specifically understand this:
data starts getting inconsistent. I start getting different volumes. I made a mistake. The Volumes don't vary, they are actually very accurate and consistent. Since I am saving the lowest volumes with their corresponding prices sometimes the lowest volume I was saving corresponded, of course, to a different price. This was caused because the Price Levels were different from last test even though I was analyzing the same bar. |