Support Board
Date/Time: Mon, 23 Dec 2024 19:51:42 +0000
Post From: ACSIL: finding first bar for the trading day
[2015-10-11 13:46:48] |
User44052 - Posts: 34 |
Just an update, the code proposed by Jack seems to go into an infinite loop if you attempt an auto-replay backtest (even without any orders). Here's the code that crashes Sierra - I have no idea why. SCSFExport scsf_findFirstBar(SCStudyInterfaceRef sc)
{ // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "First Bar"; sc.FreeDLL = 1; sc.AutoLoop = 1; //Auto looping is enabled. sc.GraphRegion = 0; sc.Subgraph[0].Name = "Dummy Line Replicates Close"; sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE; sc.Subgraph[0].PrimaryColor = RGB (0, 0, 255); return; } // Section 2 - Do data processing here int FirstBarOfDay = sc.ArraySize - 1; while (DATE_PART(sc.BaseDateTimeIn[FirstBarOfDay]) == DATE_PART(sc.BaseDateTimeIn[FirstBarOfDay - 1])) FirstBarOfDay --; sc.Subgraph[0][sc.Index] = sc.Close[sc.Index]; } |