Support Board
Date/Time: Thu, 06 Mar 2025 09:53:12 +0000
Post From: Inaccurate OHLC data in custom study
[2022-01-26 19:34:31] |
opmetal - Posts: 70 |
I noticed a bug in my code the other day and have narrowed it down to a very basic test case of unable to read OHLC data. The OHLC values that are displayed in the Message Log are not correct. For example, the Open price is always zero. I noticed this first on "Range per bar - true (in ticks)" bars and got the same on minute charts. What am I doing wrong? Thank you. test code: ----------------------------------------------------------------- #include "sierrachart.h" SCDLLName("ohlc_test") SCSFExport scsf_OHLCtest(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "ohlc_test"; sc.GraphRegion = 0; sc.AutoLoop = 1; return; } SCString DataString; DataString.Format("current bar: Open:%f High:%f Low:%f Close:%f", sc.FormatDateTime(sc.BaseDateTimeIn[sc.Index]).GetChars(), sc.Open[sc.Index], sc.High[sc.Index], sc.Low[sc.Index], sc.Close[sc.Index]); sc.AddMessageToLog(DataString, 0); } |