#include "sierrachart.h" // Name of the custom study. SCDLLName("Delta Difference") SCSFExport scsf_DeltaDifference(SCStudyGraphRef sc) { // Section 1 - Set the configuration variables SCInputRef InputData = sc.Input[0]; if (sc.SetDefaults) { // Set the configuration and defaults sc.GraphName = "Delta Difference"; sc.StudyDescription = "Delta Difference"; sc.FreeDLL = 1; // 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.AutoLoop = 1; // true //Output Graph sc.Subgraph[0].Name = "Delta Volume"; sc.Subgraph[0].DrawStyle = DRAWSTYLE_BAR; sc.Subgraph[0].PrimaryColor = RGB(0,255,0); sc.Subgraph[0].SecondaryColor = RGB(255,0,0); sc.Subgraph[0].SecondaryColorUsed = 1; //User Inputs InputData.Name = "Input Data"; InputData.SetCustomInputIndex(0); InputData.SetCustomInputStrings("Up/Down Volume;Ask/Bid Volume;Up/Down Trades"); return; } // Section 2 - Do data processing here //Select Input Data Type unsigned int Up; unsigned int Down; if(InputData.GetIndex() == 0) { Up = SC_UPVOL; Down = SC_DOWNVOL; } else if(InputData.GetIndex() == 1) { Up = SC_ASKVOL; Down = SC_BIDVOL; } else { Up = SC_ASKNT; Down = SC_BIDNT; } if (sc.BaseDataIn[Up][sc.Index] > sc.BaseDataIn[Down][sc.Index]) { sc.Subgraph[0][sc.Index] = (sc.BaseDataIn[Up][sc.Index] - sc.BaseDataIn[Down][sc.Index]); sc.Subgraph[0].DataColor[sc.Index] = sc.Subgraph[0].PrimaryColor; } else { sc.Subgraph[0][sc.Index] = (sc.BaseDataIn[Up][sc.Index] - sc.BaseDataIn[Down][sc.Index]); sc.Subgraph[0].DataColor[sc.Index] = sc.Subgraph[0].SecondaryColor; } }