Support Board
Date/Time: Mon, 25 Nov 2024 09:22:03 +0000
Post From: Data from study Study/Price overlay are not retrieved correctly on the first load,
[2024-03-18 23:03:57] |
User851058 - Posts: 9 |
My setup is as follows: I have custom study on chart(chart1) and another custom study on another chart (chart2). When chart1 is loaded, I want to read the data from chart2's study (and chart2 is also doing some calculations in this study the result of which is supposed to be send to chart1 for further analysis), so I added the "Study/Price overlay" study to chart1 and selected the correct study from chart2 to import the data from. On chart1(the one that is supposed to read the data from chart1), I have set calculationPrecedence = VERY_LOW_PREC_LEVEL and on the chart2(the one that is supposed to feed the data to chart1): CalculationPrecedence = STD_PREC_LEVEL;
I have also implemented the wait for downloading historical data, so that the study on chart1 only starts its calculation when the data are there, but my problem still exists giving me occasionally random results int IsDownloading = sc.ChartIsDownloadingHistoricalData(sc.ChartNumber);
if (IsDownloading) return; int Index = sc.Index; int& lastIndexProcessed = sc.GetPersistentInt(0); if (Index == 0) { lastIndexProcessed = 0; return; } if (Index == lastIndexProcessed) return; lastIndexProcessed = Index; Now I've noticed, that the data retrieved from chart2 vary - they are different on first load (incorrect, "random"), and when after I refresh chart1, different result is returned, but this time it returns the data correctly. As in the picture attached, on the first load of the chart1 with ticker VALE, the "isSequenceOk" flag was wrongly set to 1, but after I refreshed the chart1, the value of this flag changed to 0 (and 0 is the expected value of this flag - so correctly set only after reload).... This indicates, that there must some kind of "racing condition" between the two charts and the connected studies. Could You please guide me how to solve this issue? Tried searching the support board but couldn't find anything of help to solve this problem. The only posts I've found were about the calculationPrecedence and that the order of studies in the list matters for calculations, so I also re-ordered them (which also did not solve the problem) Date Time Of Last Edit: 2024-03-18 23:37:20
|
SCCalculation.png / V - Attached On 2024-03-18 22:53:47 UTC - Size: 217.15 KB - 63 views |