Support Board
Date/Time: Sun, 24 Nov 2024 09:47:23 +0000
Post From: Feature Request
[2024-06-19 21:07:15] |
AndyB - Posts: 101 |
Hi SC team, Following up on this thread. I believe there may be an issue with how the data recording mode handles some of the intraday data. Specifically the special values for the Open member. I coded up a study to output the values for SCID files to the message log. I ran this study on a 1 trade chart for ESM24_FUT_CME and ESM24_FUT_CME-BID_ASK_TRADE_SYNC. The "non" recording mode symbol correctly outputs the special values. However, the data recording mode only ouputs 0 (SINGLE_TRADE_WITH_BID_ASK). Per the Message Log instructions for "Send For Analysis", I am informing you that I will be sending my message log that shows the output of my study during a replay of approximately the same 20 seconds for ESM24_FUT_CME and ESM24_FUT_CME-BID_ASK_TRADE_SYNC. Here is my code: #include "sierrachart.h" SCDLLName("Unbundled Trade Volume Calculator") // Function to convert tradeType values to readable strings if necessary const char* GetTradeTypeDescription(float tradeTypeValue) { // Using a small epsilon value for float comparison const float epsilon = 0.0001f; if (fabs(tradeTypeValue - SINGLE_TRADE_WITH_BID_ASK) < epsilon) return "Single Trade with Bid/Ask"; else if (fabs(tradeTypeValue - FIRST_SUB_TRADE_OF_UNBUNDLED_TRADE_VALUE) < epsilon) return "First Sub Trade of Unbundled Trade"; else if (fabs(tradeTypeValue - LAST_SUB_TRADE_OF_UNBUNDLED_TRADE_VALUE) < epsilon) return "Last Sub Trade of Unbundled Trade"; else return nullptr; // or you can use SCString().Format("%f", tradeTypeValue) to log the raw value } SCSFExport scsf_UnbundledTradeVolumeCalculator(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Unbundled Trade Volume Calculator"; sc.StudyDescription = "Calculates the total unbundled bid and ask volumes for the current symbol from the SCID file."; sc.AutoLoop = 0; // Do not automatically loop through the chart data sc.MaintainAdditionalChartDataArrays = 1; return; } s_IntradayRecord IntradayRecord; int SubIndex = 0; int ReadSuccess = 1; bool FirstIteration = true; while (ReadSuccess) { IntradayFileLockActionEnum IntradayFileLockAction = FirstIteration ? IFLA_LOCK_READ_HOLD : IFLA_NO_CHANGE; FirstIteration = false; ReadSuccess = sc.ReadIntradayFileRecordForBarIndexAndSubIndex(sc.Index, SubIndex, IntradayRecord, IntradayFileLockAction); if (ReadSuccess) { // Extract and convert necessary values float tradeType = IntradayRecord.Open; float askPrice = IntradayRecord.High / 100.0f; float bidPrice = IntradayRecord.Low / 100.0f; float tradePrice = IntradayRecord.Close / 100.0f; unsigned int numTrades = IntradayRecord.NumTrades; unsigned int totalVol = IntradayRecord.TotalVolume; unsigned int bidVol = IntradayRecord.BidVolume; unsigned int askVol = IntradayRecord.AskVolume; // Only log if totalVol > 0 if (totalVol > 0) { const char* tradeTypeDesc = GetTradeTypeDescription(tradeType); SCString dateTimeString = sc.DateTimeToString(IntradayRecord.DateTime, FLAG_DT_COMPLETE_DATETIME_MS); SCString logMessage; logMessage.Format("SubIndex: %d, DateTime: %s, Trade Type: %s, Ask Price: %.2f, Bid Price: %.2f, Trade Price: %.2f, NumTrades: %u, Total Volume: %u, Bid Volume: %u, Ask Volume: %u", SubIndex, dateTimeString.GetChars(), tradeTypeDesc ? tradeTypeDesc : SCString().Format("%.6f", tradeType).GetChars(), askPrice, bidPrice, tradePrice, numTrades, totalVol, bidVol, askVol); sc.AddMessageToLog(logMessage, 0); } ++SubIndex; } } // Release the lock sc.ReadIntradayFileRecordForBarIndexAndSubIndex(-1, -1, IntradayRecord, IFLA_RELEASE_AFTER_READ); } Please advise if there is anything that I missed in the documentation regarding data recording modes that is causing my study to output different values for both symbols. Neither ESM24_FUT_CME or ESM24_FUT_CME-BID_ASK_TRADE_SYNC are set to 'Combine Trades Into Original Summary Trade'. I do understand that there is a work around for this, but I figured that it would be better to at least point it out to you just incase you happen to deem it important enough to look into. Thank you. |