// The top of every source code file must include this line #include "sierrachart.h" /***************************************************************************** For reference, please refer to the Advanced Custom Study Interface and Language documentation on the Sierra Chart website. *****************************************************************************/ // This line is required. Change the text within the quote // marks to what you want to name your group of custom studies. SCDLLName("PriceChangeCounter") //This is the basic framework of a study function. SCSFExport scsf_PriceChangeCounter(SCStudyGraphRef sc) { SCSubgraphRef PriceChanges = sc.Subgraph[0]; SCInputRef TextSize = sc.Input[1]; SCInputRef ShiftToRight = sc.Input[2]; // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "PriceChangeCounter"; // During development set this flag to 1, so the DLL can be rebuilt without restarting Sierra Chart. When development is completed, set it to 0 to improve performance. sc.FreeDLL = 1; sc.AutoLoop = 1; //Auto looping is enabled. sc.GraphRegion = 0; PriceChanges.Name = "PriceChanges"; PriceChanges.PrimaryColor = RGB(0,102,0); TextSize.Name = "TextSize"; TextSize.SetInt(11); TextSize.SetIntLimits(1, 50); TextSize.SetDescription("TextSize"); ShiftToRight.Name = "ShiftToRight"; ShiftToRight.SetInt(2); ShiftToRight.SetDescription("ShiftToRight"); return; } // Section 2 - Do data processing here s_UseTool Tool1; int TxtSz = TextSize.GetInt(); int RightSift = ShiftToRight.GetInt(); float TickSize = sc.TickSize; float& Last= sc.PersistVars->f1; int& Counter= sc.PersistVars->i1; double& BarTime= sc.PersistVars->d1; SCDateTime DTV = sc.BaseDateTimeIn[sc.Index]; if (BarTime!=DTV) Counter = 0; if (sc.Close[sc.Index] != Last) Counter ++; BarTime = DTV; Last = sc.Close[sc.Index]; Tool1.Clear(); Tool1.ChartNumber = sc.ChartNumber; Tool1.Tool = TOOL_TEXT; //Tool1.LineNumber = id1; Tool1.AddMethod = UTAM_ADD_OR_ADJUST; Tool1.FontSize=TxtSz; Tool1.FontBold=1; Tool1.Color=PriceChanges.PrimaryColor; Tool1.TextAlignment=DT_VCENTER|DT_RIGHT; Tool1.UseRelativeValue=0; Tool1.BeginDateTime = sc.BaseDateTimeIn[sc.Index+RightSift]; Tool1.BeginValue = sc.High[sc.Index]+1*TickSize; Tool1.Text.Format(" %i", Counter); sc.UseTool(Tool1); }