Support Board
Date/Time: Thu, 13 Feb 2025 03:16:53 +0000
[Programming Help] - Specific time of day custom chart bars not working as expected
View Count: 639
[2020-11-17 14:15:41] |
ochocinco - Posts: 29 |
The study creates a chart where the bars for each trading day have a custom time duration. For a hypothetical example, each trading day has 4 bars: bar 1 starts at futures open my time at 17:00 via evening session start time, bar 2 starts at 01:00, bar 3 starts at 10:30, bar 4 starts at 15:00 and lasts for the rest of the session. My study works on v2138, bars form as I expect. And it still compiles (SC remote build) without error on v2191, but now with v2191 the bars do not form at the correct time(s) of day. I know there are SCDateTime related changes involved with the move from v2138 to v2191, but I havent been able to solve for making this work on v2191. What approach would you use to evaluate the NewFileRecord and set the StartNewBarFlag at a specific time of each day? I'm stuck and would be happy with any suggestions. /*------------------------------------------------------------------------*/ //This code works as expected when using v2138, 17:00 evening session start #include "sierrachart.h" SCDLLName("TimeOfDayCustomBars") SCSFExport CustomChartBarBuildingFunction(SCCustomChartBarInterfaceRef ChartBarInterface) { //This is set to 0 by Sierra Chart upon each entry into this function, but just setting it here for clarity. ChartBarInterface.StartNewBarFlag = 0; // Construct a time value int Time1030 = HMS_TIME(10,30,00); int Time1500 = HMS_TIME(15,00,00); int Time100 = HMS_TIME(1,00,00); if (ChartBarInterface.IsDeterminingIfShouldStartNewBar) { /*This flag is set to 1 and this function is called after the initial processing of the intraday file record but before it is added to the most recent chart bar. Set ChartBarInterface.StartNewBarFlag to 1 to indicate to start a new bar or 0 to indicate not to start a new chart bar. */ if ( (ChartBarInterface.NewFileRecord.DateTime.GetTime() == Time1500 && ChartBarInterface.NewFileRecord.DateTime.GetMillisecond() == 0) || (ChartBarInterface.NewFileRecord.DateTime.GetTime() == Time1030 && ChartBarInterface.NewFileRecord.DateTime.GetMillisecond() == 0) || (ChartBarInterface.NewFileRecord.DateTime.GetTime() == Time100 && ChartBarInterface.NewFileRecord.DateTime.GetMillisecond() == 0) ) { ChartBarInterface.StartNewBarFlag = 1; return; } } SCSFExport scsf_TimeOfDayBars(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphRegion = 0; sc.GraphName = "Time of Day Based Custom Bars"; sc.UsesCustomChartBarFunction = 1; // This function is called from another thread. sc.fp_ACSCustomChartBarFunction = CustomChartBarBuildingFunction; sc.AutoLoop = 0;//Always use manual looping. return; } int& r_ChartDataReloadedFlag = sc.GetPersistentInt(CUSTOM_CHART_BAR_RELOAD_FLAG_KEY); if (r_ChartDataReloadedFlag == 0) { sc.FlagToReloadChartData = true; r_ChartDataReloadedFlag = 1; } } Date Time Of Last Edit: 2020-11-17 14:17:58
|
To post a message in this thread, you need to log in with your Sierra Chart account: