ACSIL Interface Members - Variables and Arrays


On This Page


Variables and Arrays

sc.ActiveToolIndex

Read Integer variable.

sc.ActiveToolIndex is the array index corresponding to the second index used with the arrays sc.BaseData[][] and sc.Subgraph[][], that the current Drawing Tool is pointing to on the chart that the study function is applied to.

This variable will not be updated when the Pointer tool is selected or when the Chart Values tool is selected, and not active.

This variable is always guaranteed to be up-to-date when sc.ReceivePointerEvents is set to 1 and the Pointer, Chart Values or Hand tools are selected, whether they are active or not.

When you use this variable it may be a good idea to set sc.UpdateAlways to 1, so that your study function is continuously called so it can be aware of the new tool position more often.

Alternatively you may want to use the Advanced Custom Study Interaction With Menus, Control Bars, Pointer Events functionality.

Example

 // Get the Open value of the bar that the tool is over
float OpenValueAtTool = sc.BaseData[SC_OPEN][sc.ActiveToolIndex];

//Get the Date-Time of the bar that the current tool is over.
SCDateTime BarDateTime = sc.BaseDateTimeIn[sc.ActiveToolIndex];

sc.ActiveToolYPosition

Read Integer variable.

sc.ActiveToolYPosition is the Y-axis coordinate in pixels of the current drawing tool's position over the chart your study function is applied to. This variable will not be updated when the Pointer tool is selected or when the Chart Values tool is selected, however not active.

When you use this variable it may be a good idea to set sc.UpdateAlways to 1, so that your study function is continuously called so it can be aware of the new tool position more often.

sc.ActiveToolYValue

Type: Read-only float variable.

The sc.ActiveToolYValue variable is the Y-axis value in the chart region that the mouse pointer is at when using one of the chart tools including the Chart Values tool. This is not the pixel position. It is the actual chart region value derived from the displayed graphs.

Example

float Value = sc.ActiveToolYValue;

sc.AlertConditionFlags

Read-only variable

sc.AlertConditionFlags will be a nonzero value when the Simple Alert Condition Formula on the the study is TRUE

Example

int AlertState = sc.AlertConditionFlags;

sc.AlertOnlyOncePerBar

Read/Write Integer variable.

sc.AlertOnlyOncePerBar can be set to 1 or 0 (TRUE/FALSE) to cause an Alert to be given only once per bar in the chart. This variable works with the sc.SetAlert() function.

sc.ArraySize

Read variable

sc.ArraySize is set to the number of array elements (equivalent to chart bars), that are in the arrays for the chart the study is applied to.

sc.ArraySize applies to the sc.BaseDateTimeIn[], sc.BaseDataIn[][], and sc.Subgraph[][] arrays.

If you set sc.IsCustomChart to 1 (TRUE), sc.ArraySize does not apply to the sc.Subgraph[][] arrays. Refer to sc.OutArraySize, for more information.

Setting sc.IsCustomChart is uncommon, so in most cases this is not applicable.

Example

// Copy all the Close elements from the BaseDataIn array
// to the Data array of the first subgraph
for (int i = 0; i < sc.ArraySize; ++i)
{
    // SC_LAST is for the Close values in OHLC bars
    sc.Subgraph[0][i] = sc.BaseDataIn[SC_LAST][i];
}

sc.Ask

Read-only float variable.

sc.Ask is the current Ask value for the symbol if Bid and Ask data is available.

During a replay, this value is set. For additional information, refer to Trade Simulation Accuracy and Bid/Ask Prices During Replays.

sc.AskSize

Read-Only integer variable.

sc.AskSize is the current size of the Ask when Bid and Ask data is available.

sc.AutoLoop

Read/Write variable.

Initial value: 0 (FALSE)

When sc.AutoLoop is set to 1 (TRUE), then sc.BaseData and sc.Subgraph[].Data[] array element looping is automatically performed. Otherwise, you will need to create your own internal loop to iterate through these arrays. It is preferred that you set sc.AutoLoop to 1 (TRUE) unless you do not require it. For a complete discussion on this, refer to Automatic Looping/Iterating.

sc.AutoLoop must only be set within the sc.SetDefaults code block at the top of the study function.

Example

if (sc.SetDefaults)
{

    sc.AutoLoop = 1; // Enable auto-looping
} 

sc.AutoScalePaddingPercentage

Read/Write float variable.

Initial value: 0

sc.AutoScalePaddingPercentage is a percentage value within the range of -1 to 1 where positive values mean more vertical scale padding, and negative values mean inverse vertical scale padding. A value of 0.4 means that padding takes up 40% of the chart, and the graph uses the rest of the 60%. This is the value that gets changed when you use the Interactive Scale Range feature when you left click and drag the scale on the right side of the chart.

Example

sc.AutoScalePaddingPercentage = 0.3f;

sc.BaseDataIn[][] / sc.BaseData[][]

Read-only. Array of float arrays.

sc.BaseDataIn[][] / sc.BaseData[][] is an array of float arrays that contain the data for the main graph in the chart. The first use of square brackets on this object will get the specified array of the main graph on the chart. For example: sc.BaseDataIn[SC_OPEN] will get the array of opening prices for each bar on the chart. The second use of square brackets will get an element inside the array that you received with the first set of square brackets.

For example: sc.BaseDataIn[SC_OPEN][sc.Index] will get the opening price for the bar at the array index your study function should do processing at when using Auto-Looping (the standard method of looping). The main graph is not necessarily the underlying data in the chart. For example, if you are using the Point and Figure study, then sc.BaseData[][] will contain the Point and Figure bar data.

For complete information about indexing and array sizes for the sc.BaseData[][] arrays, refer to the Array Indexing and Sizes section.

The following lists all of the supported sc.BaseData[] / sc.BaseDataIn[] arrays and the corresponding constants that can be used. The descriptions for each are provided. These arrays provide access to the main price graph. The direct referencing arrays are also given, such as sc.Open[].

  • sc.BaseData[SC_OPEN] or sc.Open[]: The array of opening prices for each bar.
  • sc.BaseData[SC_HIGH] or sc.High[]: The array of high prices for each bar.
  • sc.BaseData[SC_LOW] or sc.Low[]: The array of low prices for each bar.
  • sc.BaseData[SC_LAST] or sc.Close[]: The array of closing/last prices for each bar.
  • sc.BaseData[SC_VOLUME] or sc.Volume[]: The array of trade volumes for each bar.
  • sc.BaseData[SC_NUM_TRADES] or sc.NumberOfTrades[]: The array of the number of trades for each bar for Intraday charts.
  • sc.BaseData[SC_OPEN_INTEREST] or sc.OpenInterest[]: The array of the open interest for each bar for daily (historical) charts.
  • sc.BaseData[SC_OHLC]or sc.OHLCAvg[]: The array of the average prices of the open, high, low, and close prices for each bar.
  • sc.BaseData[SC_HLC] or sc.HLCAvg[]: The array of the average prices of the high, low, and close prices for each bar.
  • sc.BaseData[SC_HL] or sc.HLAvg[]: The array of the average prices of the high and low prices for each bar.
  • sc.BaseData[SC_BIDVOL] or sc.BidVolume[]: The array of Bid Volumes for each bar. This represents the volumes of the trades that occurred at the Bid price or lower. A trade that occurs between the Bid or Ask and is considered a downtick, will have the volume of that trade added to Bid Volume.
  • sc.BaseData[SC_ASKVOL] or sc.AskVolume[]: The array of Ask Volumes for each bar. This represents the volumes of the trades that occurred at the Ask price or higher. A trade that occurs between the Bid or Ask and is considered an uptick, will have the volume of the trade added to the Ask Volume.
  • sc.BaseData[SC_UPVOL] or sc.UpTickVolume: This array contains the total volume of trades for the bar where the trades occurred at a higher price than the trade before or the symbol traded at the same price as before and previously it traded higher.
    For this to work properly, the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings needs to be 1 Tick. If it is not, then when the chart is reloaded, the historical up volume can change compared to real-time updating. In the case of Number of Trades, Volume, Range, Reversal, Renko, Delta Volume chart bars, the data in this array may not be correct if Chart >>Chart Settings >> Split Data Records is enabled, unless there is 1 Tick data being used and the chart bars are based on Number of Trades or a Range.
    If you are using this array in your study function, you must set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_DOWNVOL] or sc.DownTickVolume: This array contains the total volume of trades for the bar where the trades occurred at a lower price than the trade before or the symbol traded at the same price as before and previously it traded down.
    For this to work properly, the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings needs to be 1 Tick. If it is not, then when the chart is reloaded, the historical down volume can change compared to real-time updating. In the case of Number of Trades, Volume, Range, Reversal, Renko, Delta Volume chart bars, the data in this array may not be correct if Chart >>Chart Settings >> Split Data Records is enabled, unless there is 1 Tick data being used and the chart bars are based on Number of Trades or a Range.
    If you are using this array in your study function, you must set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_BIDNT] or sc.NumberOfBidTrades: The array containing the total number of trades at the bid price or lower. For this to work properly, the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings. needs to be 1 Tick. This will also not work on historical data that does not have bid volume. In the case of Tick, Volume, and Range charts, the data in this array may not be correct if Chart >>Chart Settings >> Split Data Records is enabled, unless you are using tick data and the chart is based on Ticks or a Range.
    If you are using this array in your study function, you must set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_ASKNT] or sc.NumberOfAskTrades: The array containing the total number of trades at the ask price or higher. For this to work properly, the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings needs to be 1 Tick. This will also not work on historical data that does not have ask volume. In the case of Tick, Volume, and Range charts, the data in this array may not be correct if Chart >>Chart Settings >> Split Data Records is enabled, unless you are using tick data and the chart is based on Ticks or a Range.
    If you are using this array in your study function, you must set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_ASKBID_DIFF_HIGH]: The array containing the maximum difference between the Ask volume and the Bid volume for the bar at the specified Index. This is calculated at every tick during the creation of the bar. For the data in this array to be most accurate, the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings needs to be 1 Tick. The data in this array will not be available for historical data that does not have Ask Volume and Bid Volume.
    For the chart to maintain the data in this array, you need to set sc.MaintainAdditionalChartDataArrays to TRUE in the sc.SetDefaults code block in your study function.
  • sc.BaseData[SC_ASKBID_DIFF_LOW]: The array containing the minimum difference between the Ask volume and the Bid volume for the bar at the specified Index. This is calculated at every tick during the creation of the bar. For the data in this array to be most accurate, the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings needs to be 1 Tick. The data in this array will not be available for historical data that does not have Ask volume and Bid Volume.
    For the chart to maintain the data in this array, you need to set sc.MaintainAdditionalChartDataArrays to TRUE in the sc.SetDefaults code block in your study function.
  • sc.BaseData[SC_ASKBID_NT_DIFF_HIGH]: The array containing the maximum difference between the number of trades at the Ask price or higher and the number of trades at the Bid price or lower, for the bar at the specified Index. This is calculated at every tick during the creation of the bar. For the data in this array to be accurate, the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings must be 1 Tick. The data in this array will not be available for historical data that does not have Ask and Bid volume.
    If you are using this array in your study function, you must set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_ASKBID_NT_DIFF_LOW]: The array containing the minimum difference between the number of trades at the Ask price or higher and the number of trades at the Bid price or lower, for the bar at the specified Index. This is calculated at every tick during the creation of the bar. For the data in this array to be accurate, the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings must be 1 Tick. The data in this array will not be available for historical data that does not have Ask and Bid volume.
    If you are using this array in your study function, you must set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_UPDOWN_VOL_DIFF_HIGH]: The array containing the maximum difference between the total volume of trades for the bar where the trades occurred at a higher price than the trade before and the total volume of trades for the bar where the trades occurred at a lower price than the trade before. Also take note of the additional details explained in sc.BaseData[SC_UPVOL/SC_DOWNVOL].
    If you are using this array in your study function, you must set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_UPDOWN_VOL_DIFF_LOW]: The array containing the minimum difference between the total volume of trades for the bar where the trades occurred at a higher price than the trade before and the total volume of trades for the bar where the trades occurred at a lower price than the trade before. Also take note of the additional details explained in sc.BaseData[SC_UPVOL/SC_DOWNVOL].
    If you are using this array in your study function, you must set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_RENKO_OPEN]: In the case of a Renko chart set through Chart >> Chart Settings, this array provides the Renko Open price. This array is used to draw the Renko bar body.
  • sc.BaseData[SC_RENKO_CLOSE]: In the case of a Renko chart set through Chart >> Chart Settings, this array provides the Renko Close price. This array is used to draw the Renko bar body.
  • sc.BaseData[SC_BID_PRICE]: This array contains the bid prices at the time of the last trade for each bar.

    When using this array in a study function, it is necessary to set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_ASK_PRICE]: This array contains the ask prices at the time of the last trade for each bar.

    When using this array in a study function, it is necessary to set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.
  • sc.BaseData[SC_ASK_BID_VOL_DIFF_MOST_RECENT_CHANGE]: This array contains a value indicating whether the SC_ASKBID_DIFF_HIGH or the SC_ASKBID_DIFF_LOW array was most recently changed.

    It will be set to 1 if the SC_ASKBID_DIFF_HIGH array at the corresponding element was most recently changed. It will be set to -1 if the SC_ASKBID_DIFF_LOW array at the corresponding element was most recently changed. When using this array in a study function, it is necessary to set sc.MaintainAdditionalChartDataArrays to 1 in the sc.SetDefaults code block.

The index value returned by sc.Input[].GetInputDataIndex(), corresponds to the array index constants given above. You can use this Input to select any of these array index constants to use with sc.BaseData[].

sc.BaseData is short-hand for sc.BaseDataIn.

Example

// Get the volume at the current index.
// This requires sc.AutoLoop = 1;
float Volume = sc.BaseData[SC_VOLUME][sc.Index];

// Copy the Last price from the current index to sc.Subgraph 0
sc.Subgraph[0][sc.Index]=sc.BaseData[SC_LAST][sc.Index];

sc.BaseData References

A useful technique to make it easier to work with a single array for main price graph is to use a reference to the array. A reference to one of these arrays would be declared as SCFloatArrayRef. SCFloatArrayRef is a reference to the type of the arrays that are used in sc.BaseData[]. Below is an example of using a reference to one of the arrays in the chart.

Example

// Make a reference to the array of High prices called Highs
SCFloatArrayRef Highs = sc.BaseData[SC_HIGH];

// Get the high price at the current index
// This is the same as sc.BaseData[SC_HIGH][sc.Index]
float HighValue = Highs[sc.Index]; 

sc.BaseDateTimeIn[]

Read-only. SCDateTime array.

sc.BaseDateTimeIn[] is an array of the Date-Time for each bar in the chart. Each element is a SCDateTime. The word In at the end of this array means input, which signifies that this array is input data for your study.

For information about indexing and array sizes see Array Indexing and Sizes.

Example

// Get the DateTime at the current index.
SCDateTime BarDateTime = sc.BaseDateTimeIn[sc.Index];

Since this is a SCDateTime array, you can use the DateAt() and TimeAt() member functions to get just the date or just the time at a single bar.

Example

// Get the date
int BarDate = sc.BaseDateTimeIn.DateAt(sc.Index);

// Get the time
int BarTime = sc.BaseDateTimeIn.TimeAt(sc.Index);

sc.BasedOnGraphValueFormat

Read-only Integer variable.

This variable uses the same values as sc.ValueFormat and is set to the Value Format for the graph set with the Based On setting on an instance the study which has been applied to the chart.

sc.BaseGraphGraphDrawType

Type: Read/Write Integer variable.

sc.BaseGraphGraphDrawType is set to the Graph Draw Type for the base graph in the chart. This is also known as the main price graph. This is a read/write value and can be changed.

Supported Values:

  • GDT_CUSTOM
  • GDT_OHLCBAR
  • GDT_CANDLESTICK
  • GDT_CANDLESTICK_BODY_ONLY
  • GDT_LINEONCLOSE
  • GDT_MOUNTAIN
  • GDT_HLCBAR
  • GDT_LINEONOPEN
  • GDT_LINEONHLAVG
  • GDT_STAIRSTEPONCLOSE
  • GDT_HLBAR
  • GDT_KAGI
  • GDT_POINT_AND_FIGURE_BARS
  • GDT_POINT_AND_FIGURE_XO
  • GDT_BID_ASK_BAR
  • GDT_EQUIVOLUME
  • GDT_CANDLE_VOLUME_BAR
  • GDT_ASK_BID_DIFF_NUMBER_BAR
  • GDT_VOLUME_NUMBER_BAR
  • GDT_TRADES_NUMBER_BAR
  • GDT_BID_ASK_NUMBER_BAR
  • GDT_ASK_BID_VOL_DIFF_BAR

sc.BaseGraphScaleConstRange

Read/write Float variable.

The sc.BaseGraphScaleConstRange variable gets and sets the grayscale range for the chart base graph when it is using a Scale Type of Constant Range. For additional information, refer to the Chart Scale and Scale Adjusting documentation.

When changing the symbol of the chart, this constant range value gets reset to a default value based upon the Tick Size of the chart.

sc.BaseGraphScaleIncrement

Read/write float variable.

This sets the Scale Increment for the main price graph. When it is set to a nonzero value, it will change the Scale Increment for the main price graph.

Example

sc.BaseGraphScaleIncrement= 0;

sc.BaseGraphScaleRangeBottom

Type: Read/Write float variable.

The sc.BaseGraphScaleRangeBottom variable is the bottom/minimum value of a User Defined scale range for the main price graph in the chart.

In the user interface this setting is in Chart >> Chart Settings >> Scale >> Scale Range >> User-Defined >> Bottom of Range.

This can be modified by the custom study.

To get and set the bottom of the User Defined scale range for the study itself, use sc.ScaleRangeBottom.

Example

float ScaleBottom = sc.BaseGraphScaleRangeBottom;
            

sc.BaseGraphScaleRangeTop

Type: Read/Write float variable.

The sc.BaseGraphScaleRangeTop variable is the top/maximum value of a User Defined scale range for the main price graph in the chart.

In the user interface this setting is in Chart >> Chart Settings >> Scale >> Scale Range >> User-Defined >> Top of Range.

This can be modified by the custom study.

To get and set the top of the User Defined scale range for the study itself, use sc.ScaleRangeTop.

Example

float ScaleTop = sc.BaseGraphScaleRangeTop;
            

sc.BaseGraphScaleRangeType

Type: Read/Write variable.

Initial value: SCALE_AUTO

The sc.BaseGraphScaleRangeType member allows you to determine and set the vertical scale range type for the main price graph (base graph) in the chart. It can be any of the following values:

  • SCALE_AUTO
  • SCALE_USERDEFINED
  • SCALE_INDEPENDENT
  • SCALE_SAMEASREGION
  • SCALE_CONSTRANGE
  • SCALE_CONSTRANGECENTER

When using SCALE_USERDEFINED, it is necessary to set sc.ScaleRangeTop and sc.ScaleRangeBottom.

Example

sc.BaseGraphScaleRangeType = SCALE_AUTO;

sc.BaseGraphValueFormat

Type: Read/Write Integer variable.

The sc.BaseGraphValueFormat variable is an Integer indicating the Price Display Format/Value Format for the main graph in the chart.

This is set through Chart >> Chart Settings. It is most useful to use with the sc.FormatGraphValue() function.

Example

SCString CurrentHigh = sc.FormatGraphValue(sc.BaseData[SC_HIGH][CurrentVisibleIndex], sc.BaseGraphValueFormat);

sc.Bid

Read-only float variable.

sc.Bid is the current Bid value for the symbol if Bid and Ask data is available.

During a replay, this value is set. For additional information, refer to Trade Simulation Accuracy and Bid/Ask Prices During Replays.

sc.BidSize

Read-only integer variable.

sc.BidSize is the current size of the bid when Bid and Ask data is available.

sc.BlockChartDrawingSelection

Read/Write Integer variable.

Refer to sc.BlockChartDrawingSelection.

sc.CalculationPrecedence

Read/Write variable.

Initial value: STD_PREC_LEVEL

sc.CalculationPrecedence is a variable that can be set to 3 possible values.

The default value is STD_PREC_LEVEL (standard precedence level), and will mean your study gets calculated relative to other studies on the same chart that your custom study is applied to, based on its position in the Analysis >> Studies >> Studies to Graph list for the chart.

A value of LOW_PREC_LEVEL (low precedence level) will mean your study gets calculated after all other studies with a standard precedence level.

A value of VERY_LOW_PREC_LEVEL (very low precedence level) will mean your study gets calculated after all other studies with standard and low precedence levels. You will want to use a very low precedence level if your study depends on other studies that have low precedence level, such as Study Moving Average or a study based on other study.

The reason why you would want to set this variable to a lower precedence level, is when you are using a function such as sc.GetStudyArray().

It is not necessary to set a low precedence when you are internally calculating study formulas, like when using sc.SimpleMovAvg().

For further information about study calculation precedence, refer to Study Calculation Precedence And Related Issues.

Example

sc.CalculationPrecedence = STD_PREC_LEVEL;

sc.ChartBackgroundColor

Read/Write RGB integer color variable

sc.ChartBackgroundColor sets the background color of the chart. This does not affect the global chart background color setting, only the chart specific setting. When setting this variable, it is also necessary to set sc.UseGlobalChartColors = 0, otherwise the variable is ignored.

Example

sc.UseGlobalChartColors = 0;

sc.ChartBackgroundColor = RGB(123,123,123);

sc.ChartBarSpacing

Type: Read/Write Integer variable.

The sc.ChartBarSpacing vvariable is the spacing between the chart bars in pixels. This is for the chart your custom study is applied to.

The bar spacing can be changed by the custom study.

Example

int ChartBarSpacing = sc.ChartBarSpacing;

sc.ChartbookName

Read-only SCString variable.

sc.ChartbookName contains the name of the Chartbook that contains the chart the study is applied to.

sc.ChartDataEndDate

variable.

sc.ChartDataEndDate.

sc.ChartDataStartDate

variable.

sc.ChartDataStartDate.

sc.ChartDataType

Type: Read/write integer variable

sc.ChartDataType is set to the data type of the underlying chart. This can be either Intraday data or Daily data.

Example

if (sc.ChartDataType == DAILY_DATA)
{

    // The chart is a Historical Daily chart
}
else if (sc.ChartDataType == INTRADAY_DATA)
{
    // The chart is an Intraday chart

}

sc.ChartNumber

Type: Read variable

sc.ChartNumber is set to the identifying number of the chart that the study is applied to. This is the same number that is shown on the top line of the chart. If the identifying number of the chart calling your function is #1, then the value of sc.ChartNumber will be 1.

sc.ChartTextFont

Type: Read variable

sc.ChartTextFont is a string of the font face that is used for text on the chart in Sierra Chart. This is useful if you want to create a font that that matches the chart text.

sc.ChartTradingOrderPrice

Type: Read-only double precision floating-point variable.

When in Chart Trade Mode, the sc.ChartTradingOrderPrice variable indicates the price level that the mouse pointer is at on the chart. This applies to the chart that the study function is applied to.

sc.ChartWindowHandle

Type: Read-Only HWND variable

sc.ChartWindowHandle is the Windows API handle (HWND) for the chart window that the study is applied to. This is useful when making Windows API function calls that require a window handle. This is for advanced programming only.

sc.ChartWindowIsActive

Type: Read-only Integer variable.

The sc.ChartWindowIsActive variable is set to 1 when the chart that contains the study instance, is the active chart window within Sierra Chart. This means either that it has the focus, or it is considered the active chart window within Sierra Chart if no Sierra Chart window currently has the focus.

sc.ConnectToExternalServiceServer

Type: Write Integer variable.

Set the sc.ConnectToExternalServiceServer variable to TRUE to perform the File >> Connect to Data Feed command from within your custom study. This is not performed immediately at the time you set this to TRUE. It is only done when your study function returns.

Also see sc.DisconnectFromExternalServiceServer and sc.ReconnectToExternalServiceServer.

Example

sc.ConnectToExternalServiceServer = TRUE;

sc.ContinuousFuturesContractLoading

Type: Read-only Integer variable.

The sc.scContinuousFuturesContractLoading variable is set to 1 when a chart is in the process of loading the historical futures contract data when the Chart >> Chart Settings >> Advanced Settings >> Continuous Futures Contract option is enabled. Otherwise, if the option is not enabled or the chart is not loading the historical futures contract data, then this will be 0. This flag is useful to avoid certain processing in your study function during the loading process.

sc.CurrencyValuePerTick

Type: Read-Only Float Variable.

sc.CurrencyValuePerTick is a variable that is set to the currency value per tick of the chart your study is applied to. This is the same as the Currency Value per Tick setting set in Chart >> Chart Settings.

sc.CurrentSystemDateTime

Type: Read-Only SCDateTime variable

sc.CurrentSystemDateTime is the current Date and Time from your local computer's date and time, provided as a SCDateTime variable.

The Time Zone setting in Global Settings >> Data/Trade Service Settings is applied to this SCDateTime variable.

This member is not affected by the chart the study is applied to, when being replayed. In other words, it will always indicate the current system Date-Time.

This variable does not contain milliseconds. The resolution is to the second.

If you want to perform a particular action in a custom study at a particular time and want to make sure the study function is called at that time, then you should use sc.UpdateAlways = 1 in the sc.SetDefaults block of the study function.

Example

SCDateTime DateTime = sc.CurrentSystemDateTime;
            

sc.CurrentDateTimeForReplay

Type: Read-Only SCDateTime variable

The sc.CurrentDateTimeForReplay variable is only set when a chart is replaying. It contains the current Date-Time relative to the starting Date-Time of the replaying chart. It is based upon the elapsed amount of time since the replay was started and the replay speed.

If you want to perform a particular action in a custom study at a particular time and want to make sure the study function is called at that time, then you should use sc.UpdateAlways = 1 in the sc.SetDefaults block of the study function.

However, when there is an accelerated replay, a study function will not necessarily be called at the interval specified by the Chart Update Interval relative to the replay times. For example, if the chart is set to update every 1000 milliseconds, during an accelerated replay it will not necessarily be called every theoretical secondSpace when using sc.UpdateAlways.

Example

		SCDateTime CurrentDateTime;
		if (sc.IsReplayRunning())
			CurrentDateTime = sc.CurrentDateTimeForReplay;
		else
			CurrentDateTime = sc.CurrentSystemDateTime;
            

sc.CurrentSystemDateTimeMS

Read-only SCDateTimeMS variable.

sc.CurrentSystemDateTimeMS is the current Date and Time from your local computer's date and time, provided as a SCDateTimeMS variable.

SCDateTimeMS is derived from SCDateTime. It contains all of the same functionality, except that it is specialized for milliseconds. Comparisons done using this type are down to the nearest millisecond unlike the nearest second for SCDateTime.

The Time Zone setting in Global Settings >> Data/Trade Service Settings is applied to this SCDateTimeMS variable.

This member is not affected by the chart the study is applied to, when being replayed. In other words, it will always indicate the current system Date-Time.

This variable contains the Date-Time of the computer system down to the millisecond.

If you want to perform a particular action in a custom study at a particular time and want to make sure the study function is called at that time, then you should use sc.UpdateAlways = 1 in the sc.SetDefaults block of the study function.

Example

SCDateTimeMS DateTimeWithMilliseconds = sc.CurrentSystemDateTimeMS;
            

sc.CurrentlySelectedDrawingTool

Type: Read-only Integer variable.

sc.CurrentlySelectedDrawingTool

Example

int CurrentlySelectedDrawingTool

sc.CurrentlySelectedDrawingToolState

Type: Read-only Integer variable.

sc.CurrentlySelectedDrawingToolState set to a constant indicating the state of the active drawing tool. This will be 0 when the tool is not active and > 0 when the tool is active. For example, when actively drawing a line with the Line Tool, this will be set to 1.

Example

int ToolState =  sc.CurrentlySelectedDrawingToolState;

sc.DailyDataBarPeriod

Type: Read/Write Integer variable

sc.DailyDataBarPeriod can be set to one of the following values: 1 = Days, 2 = Weekly, 3 = Monthly, 4 = Quarterly, 5 = Yearly. Changing this value will change the Historical Chart Period setting for the chart. After changing this variable, the chart will be reloaded with the new Historical Chart Period only after the function returns. Therefore, during the current function call when you have changed this variable, the Historical chart bars will still be at the prior period.

Example

sc.DailyDataBarPeriod = 2; // Set the chart to show weekly bars

sc.DailyHigh

Type: Read-Only float variable.

sc.DailyHigh is the current daily high for the symbol.

sc.DailyHigh is the same Daily High value displayed in the Window >> Current Quote Window. This data comes from the Current Quote Data from the connect to data feed.

sc.DailyHigh is only valid when connected to the data feed.

sc.DailyHigh will be 0 during a chart replay.

sc.DailyLow

Read-only float variable.

sc.DailyLow is the current daily low for the symbol.

sc.DailyLow is the same Daily Low value displayed in the Window >> Current Quote Window. This data comes from the Current Quote Data from the connect to data feed.

sc.DailyLow is only valid when connected to the data feed.

sc.DailyLow will be 0 during a chart replay.

sc.DailyVolume

Read-only integer variable

sc.DailyVolume is the current daily volume for the symbol.

sc.DailyVolume is the same Daily Volume value displayed in the Window >> Current Quote Window. This data comes from the Current Quote Data from the connect to data feed.

sc.DailyVolume is only valid when connected to the data feed.

sc.DailyVolume will be 0 during a chart replay.

sc.DataFile

Read/Write SCString variable

sc.DataFile is a text string of the complete path and file name of the chart data file for the chart the study instance is applied to.

This text string can be changed to change the symbol of the chart.

When this is changed, the new data file will be loaded after the study function returns. So the data file will be changed before the next call into the study function which is called after the new data file is loaded.

Only the filename needs to be set. The path is ignored. The Global Settings >> General Settings >> Data Files Folder setting is used for the path.

The file extension has to be set. Use .dly for Historical charts and .scid for Intraday charts.

Example

// Specify a new chart data file
sc.DataFile = "QQQQ.scid";

sc.DataStartIndex

Read/Write variable

Initial value: 0

Set sc.DataStartIndex to the index of the first element at which subgraphs should start to be drawn. This is to prevent Sierra Chart from drawing elements at the beginning of the sc.Subgraph arrays that do not have enough prior data to be properly calculated. For example: If you have a 10-bar moving average, this value should be set to 9. It should be set to 9 instead of 10 because array index values always begin at 0.

Example

sc.DataStartIndex = 9; // Start drawing the subgraphs at element index 9 (the 10th bar)

sc.DateTimeOfLastFileRecord

Type: Read-Only SCDateTime variable

sc.DateTimeOfLastFileRecord is the Date-Time, as a SCDateTime variable, of the starting time of the last data record read from the chart data file which has been added to the chart.

sc.DateTimeOut[]

Read/Write SCDateTime array.

sc.DateTimeOut[] is an array of the DateTimes for each of the bars you have created in a study which is set up as a custom chart. Each element is a SCDateTime. This array is only used when sc.IsCustomChart is set to 1 (TRUE).

For additional information about indexing and array sizes, see Array Indexing and Sizes.

Example

// Set the element at our CustomIndex in sc.DateTimeOut to match the current index in sc.BaseDateTimeIn
sc.DateTimeOut[CustomIndex] = sc.BaseDateTimeIn[sc.Index];

sc.DaysPerBar

Read/Write Integer variable

If the sc.DailyDataBarPeriod has a value of 1 (Days), then sc.DaysPerBar is the number of days per bar on the chart. Changing this value will change the number of days per bar setting on the chart.

Example

if (sc.DailyDataBarPeriod == 1) // 1 = days

    sc.DaysPerBar = 10; // Set the chart to 10 days per bar

sc.DaysToLoadInChart

Read/write integer variable.

The sc.DaysToLoadInChart variable is the number of days of data to load within the chart. It applies to both Intraday and Historical charts.

It is equivalent to Chart >> Chart Settings >> Use Number of Days to Load >> Days to Load.

sc.DeltaVolumePerBar

Read/write integer variable.

The sc.DeltaVolumePerBar variable is the difference between the Ask Volume and Bid Volume per bar that needs to occur before a new bar is started in the chart. It only applies to Intraday charts.

This variable can be changed by the study function. Any changes to this variable will not go into effect until returning from the study function. When this value is modified, the chart will be reloaded after the study function returns. The chart reload will occur before the next call into the study function.

Example

sc.DeltaVolumePerBar;

sc.DisconnectFromExternalServiceServer

Type: Write Integer variable.

Set the sc.DisconnectFromExternalServiceServer variable to TRUE to perform the File >> Disconnect command from within your custom study. This is not performed immediately at the time you set this to TRUE. It is only done when your study function returns.

Also see sc.ConnectToExternalServiceServer and sc.ReconnectToExternalServiceServer.

Example

sc.DisconnectFromExternalServiceServer = TRUE;

sc.DisplayAsMainPriceGraph

Type: Read/Write Integer variable.

Initial value: 0 (FALSE)

If sc.DisplayAsMainPriceGraph is set to 1 (TRUE), then your study will become the main price graph for the chart. All other studies applied to the chart, will be based on it. You will also need to set sc.GraphRegion to 0, when setting this variable to 1 (TRUE). If it is set to 0 (FALSE), then your study is a standard study based on the existing main price graph.

Example

sc.DisplayAsMainPriceGraph = 1;

sc.DisplayStudyInputValues

Type: Read/Write Integer variable.

sc.DisplayStudyInputValues is equivalent to the Display Input Values setting on the Study Settings window for the study. This variable can be set to either 1 to enable that option or to 0 to disable it.

Example

sc.DisplayStudyInputValues = 1;

sc.DisplayStudyName

Type: Read/Write Integer variable.

sc.DisplayStudyName is equivalent to the Display Study Name setting on the Study Settings window for the study. This can be set to either 1 to enable that option or to 0 to disable it.

Example

sc.DisplayStudyName = 1;

sc.DLLNameUserServiceLevel

Type: Read-only 8-byte Integer variable.

sc.DLLNameUserServiceLevel is used in conjunction with the sc.IsUserAllowedForSCDLLName variable. This returns the Service Level setting for an authorized user for the custom studies DLL that the function is in and the user has been authorized to use. This value is set through the Custom DLL Studies Management control panel accessed through your account on the Sierra Chart website.

sc.DocumentationImageURL

Type: Read/Write SCString variable.

sc.DocumentationImageURL is a text string variable that can be set to an internet URL to an image providing an example of your study. For complete documentation refer to ACSIL Study Documentation Interface Members.

Example

sc.DocumentationImageURL = "http://www.sierrachart.com/images/HomePageImages/1.png";

sc.DownloadingHistoricalData

Type: Read-only Integer variable.

sc.DownloadingHistoricalData will be set to 1 when historical data is being downloaded into the chart data file for the chart, from a remote server. Otherwise, it will be set to 0.

This variable can be useful when calling functions that play alert sounds. For example, if this is set to 1, then avoid calling the sc.PlaySound() function because many alerts may be generated by your study function from historical data being downloaded.

If historical data is not being downloaded into the chart data file for the chart, this variable will be 0 even when the chart data is being read from the local data file.

Example

if (sc.DownloadingHistoricalData == 0)

    sc.PlaySound(1,"My Alert Message");

sc.DrawBaseGraphOverStudies

Type: Read/Write Integer variable.

The sc.DrawBaseGraphOverStudies variable is the same as the Chart >> Chart Settings >> Display Main Chart Graph on Top of Studies setting. When it is set to a nonzero value, then the main chart graph will be displayed on top of other studies on the chart. Otherwise, the studies will be on top of the main chart graph.

Example

sc.DrawBaseGraphOverStudies = 1;

sc.DrawStudyUnderneathMainPriceGraph

Type: Read/Write Integer variable.

When the sc.DrawStudyUnderneathMainPriceGraph variable is set to 1 (TRUE) the study will be displayed underneath the main price graph in the chart. Assuming sc.GraphRegion is set to 0. Otherwise, this variable is not relevant. When sc.DrawStudyUnderneathMainPriceGraph is set to 0 (FALSE), then the study is displayed above the main price graph in the chart.

Example

sc.DrawStudyUnderneathMainPriceGraph = 1;

sc.EndTime1

Read/Write Integer Variable

sc.EndTime1 is the first end time for a day on the chart. This is a time value given as the number of seconds since midnight. For more information about how this variable can be used, refer to SCDateTime.

sc.EndTime2

Read/Write Integer Variable

sc.EndTime2 is the second end time for a day on the chart. This is only used if sc.UseSecondStartEndTimes is set to 1 (TRUE). This is a time value given as the number of seconds since midnight. For more information about how this variable can be used, refer to SCDateTime.

sc.ExternalServiceUsername

Type: Read-only SCString variable.

The sc.ExternalServiceUsername is a text string containing the username for the currently selected external Data or Trading service in Sierra Chart.

sc.FileRecordIndexOfLastDataRecordInChart

Read Integer variable

The sc.FileRecordIndexOfLastDataRecordInChart variable is the index of the last Intraday data record read from the Intraday data file or the file cache, used in the chart.

This is not necessarily the very last data record in the file. For example, if a replay is in progress, it can be earlier than the last record in the file or file cache.

In newer versions of Sierra Chart, due to file caching, this variable could refer to an index which has not yet been written to the Intraday data file.

sc.FilterChartVolumeGreaterThanEqualTo

Read/Write Float variable.

sc.FilterChartVolumeGreaterThanEqualTo is for setting and getting the Volume Filter value which excludes volume greater than or equal to the specified value.

This is the same Volume Filter >= value set through Chart >> Chart Settings.

sc.FilterChartVolumeLessThanEqualTo

Read/Write Float variable.

sc.FilterChartVolumeLessThanEqualTo is for setting and getting the Volume Filter value which excludes volume less than or equal to the specified value.

This is the same Volume Filter <= set through Chart >> Chart Settings.

sc.FlagFullRecalculate

Write only integer variable.

The sc.FlagFullRecalculate variable can be set to 1 or a nonzero value to cause a full recalculation of all studies on the chart to occur after returning from the study function.

A full recalculation means in the case of automatic looping that the study function will be called for each bar in the chart starting at sc.Index 0. In the case of manual looping, the study function will be called and sc.UpdateStartIndex will be set to 0.

It is not recommended to use this because it is highly inefficient. Generally the reason this is used is due to programming problems within the study function itself and this is not an appropriate solution in those cases.

sc.FlagToReloadChartData

Write only integer variable.

The sc.FlagToReloadChartData variable can be set to 1 or a nonzero value to cause a reload of the chart data from the data file after the study function returns. The reload does not happen immediately.

This reload is the same as selecting Chart >> Reload and Recalculate on the menu.

sc.FreeDLL

Read/Write Integer variable.

Initial value: 0 (FALSE)

sc.FreeDLL can be a TRUE (1) or FALSE (0) value indicating whether or not to free the DLL (dynamic link library) your study is located in after running your study function. Set this to 0 (FALSE) to tell Sierra Chart not to free the DLL. As of version 752, the default is 0. Previously this was 1 by default. Setting it to 0 (FALSE) will significantly speed up calling your Advanced Custom Study function because the overhead of loading and freeing the DLL will be eliminated. It is critical with Sierra Chart versions 297 and higher that after your study development is done that you set this member to FALSE (0). Otherwise, CPU usage will be noticeably increased. The disadvantage of setting this to FALSE (0) is you can not make changes to your function source code while Sierra Chart is running since the DLL file is opened, locked and cannot be modified. For this reason, you should set sc.FreeDLL to 1 (TRUE), while developing your study, and set it to 0 (FALSE) once you are finished.

Example

sc.FreeDLL = 0; // Do not unload the DLL every time this function is called

sc.GlobalDisplayStudyNameSubgraphNamesAndValues

Type: Read/Write Integer variable.

sc.GlobalDisplayStudyNameSubgraphNamesAndValues is equivalent to the Display Study Name, Subgraph Names and Subgraph Values - Global setting on the Study Settings window for the study. This can be set to either 1 to enable that option or to 0 to disable it.

Example

sc.GlobalDisplayStudyNameSubgraphNamesAndValues = 1;

sc.GraphDrawType

Read/Write variable.

Initial value: GDT_CUSTOM

sc.GraphDrawType can be set to one of the values in the list below.

When you use GDT_CUSTOM, which is the default, then your study will be able to use the sc.Subgraph[].DrawStyle member to set the style for each subgraph.

When you use a setting other than GDT_CUSTOM, then the Graph Draw Type will be a type of price bar which uses the data in the sc.Subgraph[0 through 4].Data arrays. Use the: sc.Subgraph[SC_OPEN][] array for Open values, sc.Subgraph[SC_HIGH][] array for High values, sc.Subgraph[SC_LOW][] array for Low values, and the sc.Subgraph[SC_LAST][] array for Close or Last values.

In the case of GDT_CANDLE_VOLUME_BAR, use the sc.Subgraph[SC_VOLUME].Data[] array to control the width of the candlestick.

If you set this to a value other than GDT_CUSTOM and you also set the sc.DisplayAsMainPriceGraph variable to 1 (TRUE), you should calculate the average values and fill in the sc.Subgraph[SC_VOLUME][] and sc.Subgraph[SC_NUM_TRADES][] arrays. To calculate the averages, make a call to sc.CalculateOHLCAverages() near the end of your function.

When you use a sc.GraphDrawType setting value other than GDT_CUSTOM, then the sc.Subgraph[].DrawStyle variable is automatically set for each of the relevant sc.Subgraphs needed by the sc.GraphDrawType. You cannot change them.

Additionally, it is not possible when you are drawing a price bar type of graph (sc.GraphDrawType not equal to GDT_CUSTOM), to also use standard study lines or other Draw Styles using sc.Subgraph[4] and higher which are not used by the price bar graph draw types. In this case you will need to use a separate study.

Colors when using sc.GraphDrawType != GDT_CUSTOM: When using a sc.GraphDrawType that is not equal to GDT_CUSTOM, the PrimaryColor and SecondaryColor members of sc.Subgraph set the color of the bars. For more information, refer to Color Settings for Graph Draw Types. If you wish to color certain bars a certain type of color when using a price bar graph draw type, then you can use the sc.Subgraph[0-4].DataColor[] arrays.

Supported Values:

  • GDT_CUSTOM
  • GDT_OHLCBAR
  • GDT_CANDLESTICK
  • GDT_CANDLESTICK_BODY_ONLY
  • GDT_LINEONCLOSE
  • GDT_MOUNTAIN
  • GDT_HLCBAR
  • GDT_LINEONOPEN
  • GDT_LINEONHLAVG
  • GDT_STAIRSTEPONCLOSE
  • GDT_HLBAR
  • GDT_KAGI
  • GDT_POINT_AND_FIGURE_BARS
  • GDT_POINT_AND_FIGURE_XO
  • GDT_BID_ASK_BAR
  • GDT_EQUIVOLUME
  • GDT_CANDLE_VOLUME_BAR

In the case of when using GDT_POINT_AND_FIGURE_XO, if the Box Size is greater than the chart Tick Size, then it is necessary to set sc.PointAndFigureXOGraphDrawTypeBoxSize to the Box Size.

To set the Graph Draw Type for the main price graph, it is necessary to use sc.BaseGraphGraphDrawType instead.

Example

sc.GraphDrawType = GDT_OHLCBAR;

sc.GraphName

Read/Write variable.

sc.GraphName is the name of your study. This must be set when sc.SetDefaults is 1 (TRUE).

Example

sc.GraphName = "My Study";

sc.GraphRegion

Read/Write variable.

Initial value: 1 or the next unused Chart Region.

sc.GraphRegion is the zero-based index of the Chart Region for the study graph to be displayed in. A value of 0 means Chart Region 1, which is where the main price graph is drawn. A value of 1 means Chart Region 2, which is directly under the main price graph.

Currently there are 8 Chart Regions available. Therefore, the maximum value can be 7.

It is not possible for a single study to draw in a Chart Region outside of what is specified with sc.GraphRegion .

Example

sc.GraphRegion = 0; // Use the main price graph region

sc.GraphShortName

Type: Read-only SCString variable.

sc.GraphShortName is a text string that is set to the Short Name set for the instance of the study function applied to the chart.

Example

SCString ShortName = sc.GraphShortName;

sc.GraphUsesChartColors

Read/Write Integer variable.

The sc.GraphUsesChartColors variable only applies when the sc.GraphDrawType is set to one of the price bar types like GDT_OHLCBAR .

When sc.GraphUsesChartColors is set to TRUE (1), this means that the colors of the drawn price bars will be set according to the colors specified for the chart itself and not the study sc.Subgraph[] colors. These chart colors can either be the global color settings, or the chart specific color settings.

When sc.GraphUsesChartColors is set to FALSE (0), this means that the colors of the drawn price bars will be set according to the colors specified by the study sc.Subgraph[] colors.

For additional details, refer to Color Settings for Graph Draw Types.

Example

 
sc.GraphUsesChartColors  = TRUE;
            

sc.HideDLLAndFunctionNames

Type: Read/Write Integer variable.

sc.HideDLLAndFunctionNames

Example

int HideDLLAndFunctionNames

sc.HideStudy

Type: Read/Write Integer variable.

Initial Value: 0.

sc.HideStudy can be set to 1 (TRUE) to prevent the study from being displayed on the chart. Or set it to 0 (FALSE), to display the study.

Example

sc.HideStudy = 1;

sc.HistoricalHighPullbackVolumeAtPriceForBars

Type: Read-only custom data array object of type c_VAPContainer.

The sc.HistoricalHighPullbackVolumeAtPriceForBars is like the sc.VolumeAtPriceForBars array. The data that it contains is the Volume at Price data for each bar in the chart, since the last price pullback from the bar High.

The data in this array will only be maintained when you have enabled Historical Pullback Data in Chart >> Chart Settings. For complete details, refer to the Historical Pullback Data section in the Chart Settings documentation.

sc.HistoricalLowPullbackVolumeAtPriceForBars

Type: Read-only custom data array object of type c_VAPContainer.

The sc.HistoricalHighPullbackVolumeAtPriceForBars is like the sc.VolumeAtPriceForBars array. The data that it contains is the Volume at Price data for each bar in the chart, since the last price pullback from the bar Low.

The data in this array will only be maintained when you have enabled Historical Pullback Data in Chart >> Chart Settings. For complete details, refer to the Historical Pullback Data section in the Chart Settings documentation.

sc.HistoricalPriceMultiplier

sc.CurrentIndex / sc.Index

Read-only Integer variable.

sc.CurrentIndex and sc.Index are the same. They are two different variables that are set to the same index value always. You can use either one. Normally the documentation will refer to sc.Index. sc.Index is equal to the elements in the sc.BaseDataIn[][] arrays that need to be processed and/or the elements in the sc.Subgraph[][] arrays that need to be filled in.

If you are creating a custom chart by setting sc.IsCustomChart to 1 (TRUE), this is very unlikely, then sc.Index only refers to the elements in the sc.BaseDataIn[][] arrays to process, assuming your custom chart function uses the sc.BaseDataIn[][] arrays.

For complete information, refer to Automatic Looping/Iterating.

sc.IndexOfFirstVisibleBar

Read variable

sc.IndexOfFirstVisibleBar is the index into the sc.BaseData[][] arrays for the first visible bar that is drawn on the chart. When the chart is first loaded, this index will be 0.

If the study function relies on this member and it needs to be aware of changes such as when the user scrolls the chart, then you will need to set sc.UpdateAlways to 1 (TRUE).

In the case where the study is replacing the main price graph because the study function has set sc.DisplayAsMainPriceGraph = 1 or it has set sc.IsCustomChart = 1, then as explained previously, this will be set to the index into the sc.BaseData[][] arrays, and not to the index into the resulting output array.

Example

 // Get the Close value of the first bar that is drawn
float Value = sc.BaseData[SC_LAST][sc.IndexOfFirstVisibleBar];

sc.IndexOfLastVisibleBar

Read variable

sc.IndexOfLastVisibleBar is the index into the sc.BaseData[][] arrays for the last visible bar that is drawn on the chart. When the chart is first loaded, this index will be 0.

If the study function relies on this member and it needs to be aware of changes such as when the user scrolls the chart, then you will need to set sc.UpdateAlways to 1 (TRUE).

In the case where the study is replacing the main price graph because it has set sc.DisplayAsMainPriceGraph = 1 or it has set sc.IsCustomChart = 1, then as explained previously, this will be set to the index into the sc.BaseData[][] arrays, and not to the index into the resulting output array.

Example

 // Get the Close value of the last bar that is drawn
float Value = sc.BaseData[SC_LAST][sc.IndexOfLastVisibleBar];

sc.IntradayDataStorageTimeUnit

Type: Read-only Integer variable.

sc.IntradayDataStorageTimeUnit is the Intraday Data Storage Time Unit setting in Global Settings >> Data/Trade Service Settings. For more information, refer to Data/Trade Service Settings.

Example

int IDSTU = sc.IntradayDataStorageTimeUnit;

sc.IntradayChartRecordingState

Type: Read-only Integer variable.

The sc.IntradayChartRecordingState variable indicates the current state related to the writing of data to the Intraday data file for the symbol of the chart the study instance is applied to. This is useful to prevent certain processing from occurring in the study function based on this state.

It can be one of the following values:

  • IDFRS_NOT_RECORDING_DATA
  • IDFRS_HISTORICAL_DATA_DOWNLOAD_PENDING
  • IDFRS_DOWNLOADING_HISTORICAL_DATA
  • IDFRS_RECEIVING_REALTIME_DATA
  • IDFRS_FINISHED_RECEIVING_DATA

sc.IsAutoTradingEnabled

Type: Read-only Integer variable.

The sc.IsAutoTradingEnabled variable indicates the state of the Trade >> Auto trading Enabled menu command. A value of 1 means the option is enabled. A value of 0 means it is disabled.

Example

if(sc.IsAutoTradingEnabled)
{
}
            

sc.IsCustomChart

Read/Write Integer variable.

Initial value: 0 (FALSE)

Set sc.IsCustomChart to 1 (TRUE) in the sc.SetDefaults code block to make to make the study work as a custom chart.

A custom chart is used when you need to create a bar chart or some other style chart that is of a different size, either or smaller or greater, than the underlying data it is based on. In other words, either smaller or greater than the existing price bars in the chart.

When the study functions as a custom chart, the study needs to control the size of its sc.Subgraph[].Data arrays by using the sc.ResizeArrays() and sc.AddElements() functions. The study will also need to set the Date-Times of each chart bar in the sc.DateTimeOut[] array.

For a complete example, refer to the scsf_CopyOfBaseGraph() function in the /ACS_Source/CustomChart.cpp file in the Sierra Chart installation folder.

You may want to use a custom chart to create your own specialized Range bar chart or Point and Figure chart.

The /ACS_Source/CustomChart.cpp file in the folder where Sierra Chart is installed to, provides an example of a simple custom chart. The scsf_PointAndFigureChart function in the /ACS_Source/studies8.cpp file provides a more advanced example.

Example

sc.IsCustomChart = 1; // Set this study as a custom chart

sc.GraphRegion = 0; // Custom charts need to be set to use chart region 0

sc.IsFullRecalculation

Type: Read-only Integer variable.

The sc.IsFullRecalculation variable will be set to 1 (TRUE) when the chart is performing a full recalculation of the studies.

For more information about a full recalculation, refer to the Working with ACSIL Arrays and Understanding Looping page.

This flag is useful to not perform certain processing in the study function when there is a full recalculation for efficiency or to perform certain initializations in the study function when there is a full recalculation.

Example

int& Variable1 = sc.GetPersistentInt(1);
if(sc.IsFullRecalculation)
{
    Variable1 = 0;
}
            

sc.IsUserAllowedForSCDLLName

Type: Read-only Integer variable.

sc.IsUserAllowedForSCDLLName is used to authorize access to a study. For more information refer to Redistributing and Allowing Use Only by a Defined List of Users.

It is also possible to specify a Service-Level for an authorized user for a particular SCDLLName in the Custom DLL Studies Management control panel accessed through your account on the Sierra Chart website. To access this service level programmatically, refer to sc.DLLNameUserServiceLevel.

sc.LastCallToFunction

Integer read-only variable.

sc.LastCallToFunction is set to 1 (TRUE) when your Advanced Custom Study is in the process of being removed from the chart or the chart is being closed. This variable is useful if you want to do something before the study is removed from the chart or when the chart is being closed.

Example

if (sc.LastCallToFunction)
{

    // This study is being removed from the chart or the chart is being closed
    // Insert cleanup code here
}

sc.LastSize

Read-Only integer variable.

sc.LastSize is the volume of the last trade. This member will only be set when Sierra Chart is connected to the data feed and receiving current market data for the symbol of the chart, or during a chart replay.

This value for the chart is displayed in the Window >> Current Quote Window.

Example

int LastTradeSize = sc.LastSize;

sc.LastTradePrice

Read-Only Float Variable.

sc.LastTradePrice is the last trade price for the symbol of the chart the study is applied to.

This is the same value as LastPrice in Window >> Current Quote Window.

sc.LastTradePrice usually will be equal to sc.BaseData[SC_LAST][sc.ArraySize -1] except when the Session Times in Chart Settings are excluding the data from the current time. In this last case, it will be set to the actual last trade price.

This member will only be set when Sierra Chart is connected to the data feed and a nonzero last trade price in the current quote data is being provided by the data feed.

This member will be set during a chart replay.

sc.LatestDateTimeForLastBar

Type: Read-Only SCDateTime variable

The sc.LatestDateTimeForLastBar variable is set to the Date-Time, as a SCDateTime value, of the very latest trade from the data feed that is included in the last bar in the chart. The data feed has a resolution down to the second. Or, it will be set to the starting Date-Time of the very latest chart data file record which has been read into the chart, whichever is greater.

The Date-Time of the latest data file record read into the chart, is affected by the Intraday Data Storage Time Unit . If this is set to greater than 1 second, then the Date-Time of that data file record may not be set to the most recent second received in that record.

During a replay, sc.LatestDateTimeForLastBar will always be set to the Date-Time of the latest data file record read into the chart.

sc.LatestDateTimeForLastBar is adjusted to the Sierra Chart Time Zone setting.

Example

SCDateTime DateTime = sc.LatestDateTimeForLastBar;

sc.LoadChartDataByDateRange

Type: Read/Write Integer variable.

sc.LoadChartDataByDateRange

sc.MaintainAdditionalChartDataArrays

Type: Read/Write Integer variable.

sc.MaintainAdditionalChartDataArrays needs to be set to 1 (TRUE) to flag that the chart needs to maintain the following sc.BaseGraph[] arrays. This should be set in the sc.SetDefaults code block at the beginning of the function. These are the constants for these arrays:

  • SC_UPVOL
  • SC_DOWNVOL
  • SC_BIDNT
  • SC_ASKNT
  • SC_ASKBID_DIFF_HIGH
  • SC_ASKBID_DIFF_LOW
  • SC_ASKBID_NT_DIFF_HIGH
  • SC_ASKBID_NT_DIFF_LOW

When sc.MaintainAdditionalChartDataArrays is set to 0 (FALSE), these arrays are not maintained by the chart.

Example

sc.MaintainAdditionalChartDataArrays = 1;

sc.MaintainTradeStatisticsAndTradesData

Type: Read/Write Integer variable.

If your study function uses the ACSIL Trading functions, uses the s_SCPositionData structure, or uses the sc.GetTradeStatisticsForSymbol() function, then sc.MaintainTradeStatisticsAndTradesData needs to be set to TRUE in the study function in order to maintain the necessary data for this functionality to all work properly.

Example

if(sc.SetDefaults)
{
    sc.MaintainTradeStatisticsAndTradesData = TRUE;
}

sc.MaintainVolumeAtPriceData

Type: Read/Write Integer variable.

Set sc.MaintainVolumeAtPriceData to 1 (TRUE), to have Sierra Chart maintain detailed volume at price data for the loaded bars in the chart your custom study is applied to.

Example

if (sc.SetDefaults)
{
    sc.MaintainVolumeAtPriceData = 1;
}

sc.NewBarAtSessionStart

Type: Read-only Integer variable.

sc.NewBarAtSessionStart

Example

int NewBarAtSessionStart

sc.NumberOfArrays

Read variable

Initial value: 1

sc.NumberOfArrays is the number of sc.Subgraph[].Data[] arrays that are allocated for the study to use. This gets set automatically as you use the sc.Subgraph[].Data[] arrays.

Example

// Loop through all of the subgraph arrays that are used
for (int SubgraphIndex = 0; SubgraphIndex < sc.NumberOfArrays; ++SubgraphIndex)
{
    sc.Subgraph[SubgraphIndex].Data[0] = 0;
}

sc.NumFillSpaceBars

Read/Write variable

sc.NumFillSpaceBars is the number of bars in the fill space.

Example

// Make sure there are at least 10 bars of fill space
if (sc.NumFillSpaceBars < 10)

    sc.NumFillSpaceBars = 10;

sc.OnExternalDataImmediateStudyCall

Read/Write Integer variable.

Set sc.OnExternalDataImmediateStudyCall (previously sc.ExternalDataImmediateStudyCall in versions 1016 and earlier) to TRUE in the sc.SetDefaults to cause your study function to be immediately called when there is new trade market data received for the symbol of the chart the trading study is on, or there is an order update. The study function is not immediately called when there is a change with bid/ask data or market depth. Only when there is a trade or there is an order update.

This can be set to TRUE anywhere within a study function but it should be set in sc.SetDefaults to cause the study function to be called immediately upon the first market data or order update. sc.OnExternalDataImmediateStudyCall can be set to FALSE anywhere within the study function at any later time to disable this immediate calling.

Use this with caution because it will increase CPU load or could cause Sierra Chart to freeze. When setting this to TRUE, you need to evaluate the overall performance of your trading study and of Sierra Chart to determine whether this is practical to use. It should be acceptable to use, as long as you have a dedicated copy of Sierra Chart used for the purpose of monitoring a small set of symbols and has a small set of charts open.

sc.OutArraySize

Read Integer variable

sc.OutArraySize is the number of array elements (equivalent to chart bars) that are in the output arrays for the chart the study is applied to.

This includes the sc.Subgraph[].Data[] arrays, the sc.Subgraph[].DataColor[] arrays if used, and the sc.DateTimeOut[] array.

Normally sc.OutArraySize is the same as sc.ArraySize. However, in the case when sc.IsCustomChart is used, the output arrays can have a different number of elements than the sc.BaseData[][] arrays.

sc.OutArraySize is updated when you use the sc.ResizeArrays() and sc.AddElements() functions.

Example

// Resize the output arrays to be half the current size of the output arrays
sc.ResizeArrays(sc.OutArraySize / 2);

sc.PersistVars

Type: C++ pointer to structure of Read/Write variables of Integer, single precision float, and double precision float types.

Initial Value: 0 (for all the persistent variables in the structure)

sc.PersistVars is a C++ pointer to a data structure of many persistent variables of various common data types that you can use.

sc.PersistVars is only for back compatibility. Use the new GetPersistent* functions instead.

You may want to have the value in a variable remain persistent between calls to your study function. For example, when using Automatic-Looping, the default and recommended method of looping, your study function is called for every bar the chart. If you wish to have a variable retain its value between calls into your study function, then you need to use Persistent Variables.

There are a large number of predefined persistent variables which are reserved for you to use for whatever purpose you need in your study function. These variables remain persistent between calls to your study function. However, they are not saved when a chartbook is saved and closed, or when Sierra Chart is closed. They are unique to each and every instance of your study.

If you want to have permanent storage that is saved when a chartbook is saved, then you will need to use the sc.StorageBlock instead.

Persistence of Persistent Variables: Persistent variables remain persistent until the study is removed from the chart or when a chart is closed either individually or when a chartbook is closed that the chart is part of. Therefore, when a study is added to a chart either through the Chart Studies window or through Study Collections, persistent variables are initially set to 0. When a chart that is saved as part of a chartbook is opened, all of the persistent variables for all of the studies on that chart, are set to 0.

References to Persistent Variables: You can use C++ references to give names to the persistent variables by defining new variables that refer to the persistent variables. This is helpful because it makes your code easier to understand and work with. This is demonstrated in the examples below.

All persistent variables are set to zero values when an instance of the study is added to the chart or when a Chartbook is loaded and an instance of the study is contained on a chart in the Chartbook.

Available Persistent Variables

  • sc.PersistVars->i1 through sc.PersistVars->i16. Integer data type.
  • sc.PersistVars->f1 through sc.PersistVars->f16. Single precision floating-point data type.
  • sc.PersistVars->d1 through sc.PersistVars->d24. Double precision floating-point data type.
  • sc.PersistVars->scdt1 through sc.PersistVars->scdt8. SCDateTime variable type.
  • sc.PersistVars->Integers[64]. Integer data type.
  • sc.PersistVars->Doubles[64]. Double precision floating-point data type.

Example

// You can use references to give the persistent variables
// more descriptive names that you can use.

// MyCounter is a reference to sc.PersistVars->Integers[0]
int& MyCounter = sc.PersistVars->Integers[0];

// MyAverage is a reference to sc.PersistVars->Doubles[2]
double& MyAverage = sc.PersistVars->Doubles[2];

// We are using the reference we made above.
// This is the same as: sc.PersistVars->Integers[0] += 1;
MyCounter += 1;

// We are using the reference we made above.
// This is the same as: sc.PersistVars->Doubles[2] = (10.0f+24.0f)/2.0f;
MyAverage = (10.0f+24.0f)/2.0f;

// We are using the reference we made above.
MyAverage = (sc.Subgraph[2][sc.Index]+24.0f)/2.0f; 

Resetting Persistent Variables Example

if (sc.Index == 0)
{

    // When there is a full recalculation of the study,
    // reset the persistent variables we are using
    sc.PersistVars->Integers[0] = 0;
    sc.PersistVars->Integers[1] = 0;

    sc.PersistVars->Integers[2] = 0;
    sc.PersistVars->Integers[3] = 0;
}

sc.PointAndFigureXOGraphDrawTypeBoxSize

Read write Float variable.

In the case of when sc.GraphDrawType is set to GDT_POINT_AND_FIGURE_XO, sc.PointAndFigureXOGraphDrawTypeBoxSize sets the Box Size for the X and O boxes.

sc.PreserveFillSpace

Read/Write Integer variable

This is the same as the Lock Fill Space command on the Chart menu.

Set sc.PreserveFillSpace to 1 (TRUE) to prevent the fill space from being filled in as new bars are added to the chart or when the chart is being scrolled. Set it to 0 (FALSE) to allow the fill space to be filled in.

sc.PreviousClose

Type: Read-only Integer variable.

sc.PreviousClose

Example

float PreviousClose

sc.ProcId

Read Integer variable

sc.ProcId is the ID of Sierra Chart process. This variable is for advanced programming only.

sc.ProtectStudy

sc.PullbackVolumeAtPrice

Type: Read-only custom data array object of type c_VAPContainer.

The sc.PullbackVolumeAtPrice array has the same type of data that is contained within the sc.VolumeAtPriceForBars array. It only contains data for the last bar in the chart. It contains the volume data for each price level since the last price pullback from the last bar High or Low.

The data contained in this array is what is displayed in the Numbers Bars study in the Pullback column, and could be a high or low pullback based on the current bar state. This data is maintained when sc.MaintainVolumeAtPriceData is set to 1 (TRUE) in your custom study function.

When specifying the BarIndex parameter with the various VAP container functions, you must always use 0 for this parameter, since this array only contains data for a single bar.

sc.RangeBarType

Read/Write Integer variable.

sc.RangeBarType is set to, or can be set to one of the following values:

  • IBPT_RANGE_IN_TICKS_STANDARD
  • IBPT_RANGE_IN_TICKS_NEWBAR_ON_RANGEMET
  • IBPT_RANGE_IN_TICKS_TRUE
  • IBPT_RANGE_IN_TICKS_FILL_GAPS

sc.RangeBarValue

Read/Write Float variable.

sc.RangeBarValue is based on the Range Per Bar setting for the chart. This member is not in ticks, but instead is the actual range value.

This variable can be changed by the study function effective from version 1166 and higher. Any changes to this variable will not go into effect until returning from the study function. When this value is modified, the chart will be reloaded after the study function returns. The chart reload will occur before the next call into the study function.

sc.RealTimePriceMultiplier

sc.ReceivePointerEvents

Read/Write Integer Variable.

Set this to 1 (TRUE) for the study function to receive mouse pointer events when one of the ACS Tool # Control Bar buttons is enabled. For more information, refer to Advanced Custom Study Interaction With Menus, Control Bar Buttons, Mouse Pointer Events.

sc.ReconnectToExternalServiceServer

Type: Write Integer variable.

Set the sc.ReconnectToExternalServiceServer variable to TRUE to perform the File >> Disconnect and then the File >> Connect to Data Feed commands from within your custom study. This is not performed immediately at the time you set this to TRUE. It is only done when your study function returns.

Also see sc.DisconnectFromExternalServiceServer and sc.ConnectToExternalServiceServer.

Example

sc.ReconnectToExternalServiceServer = TRUE;

sc.RenkoReversalOpenOffsetInTicks

sc.RenkoTicksPerBar

Read/Write Integer variable

sc.RenkoTicksPerBar is the number of Ticks for Renko chart bars. Each tick is equivalent to the chart Tick Size.

This variable can be changed by the study function. Any changes to this variable will not go into effect until returning from the study function. When this value is modified, the chart will be reloaded after the study function returns. The chart reload will occur before the next call into the study function.

Example

sc.RenkoTicksPerBar = 10;

//Set the graph draw type to Renko bars with wicks.
sc.BaseGraphGraphDrawType = GDT_RENKO_WICK;
                

sc.RenkoTrendOpenOffsetInTicks

sc.ReplayStatus

Type: Read-only Integer variable.

The sc.ReplayStatus variable indicates the current replay status for the chart the study is applied to. It can be one of the following constants:

  • REPLAY_STOPPED: The chart is not replaying.
  • REPLAY_RUNNING: The chart is replaying.
  • REPLAY_PAUSED: The chart is considered in a replaying state, however the replay is paused.

Example

int ReplayStatus = sc.ReplayStatus;

sc.ResetAlertOnNewBar

Read/Write Integer variable.

sc.AlertOnlyOncePerBar can be set to 1 or 0 (TRUE/FALSE) to force an alert set with sc.SetAlert() to reset when there is a new bar. This works with the sc.SetAlert() function.

sc.ReversalTicksPerBar

Read/Write Integer variable.

sc.ReversalTicksPerBar is the number of Ticks for Reversal chart bars.

This variable can be changed by the study function. Any changes to this variable will not go into effect until returning from the study function. When this value is modified, the chart will be reloaded after the study function returns. The chart reload will occur before the next call into the study function.

Example

sc.ReversalTicksPerBar = 4;
                

sc.RoundTurnCommission

Read-only Integer variable.

sc.RoundTurnCommission is the Round Turn Commission set for the symbol or symbol pattern in the Global Symbol Settings.

If the chart the study instance is on is open at the time that you have set the Round Turn Commission or changed this value in the Global Symbol Settings, it is necessary to go to that chart and select Chart >> Reload and Recalculate, to be able to access the value using sc.RoundTurnCommission.

sc.SaveChartImageToFile

Write-only Integer variable.

Set sc.SaveChartImageToFile to 1 or a nonzero number, to flag to save an image of the chart the study is applied to, to a file in the Images subfolder in the folder where Sierra Chart is installed to. This operation is performed after your study function returns and all other studies on a chart are calculated. The saving operation is performed when the chart is next updated which occurs at the Chart Update Interval setting in Global Settings >> General Settings. The Filename is the Symbol of the chart plus a timestamp which includes resolution down to the millisecond.

sc.ScaleBorderColor

Type: Read/Write Integer variable.

sc.ScaleBorderColor

Example

unsigned int ScaleBorderColor

sc.ScaleConstRange

Read/Write variable.

Initial value: 0

sc.ScaleConstRange is the range, that is the difference between the high and the low, for the constant range scale types. This is only used when sc.ScaleRangeType is either SCALE_CONSTRANGE or SCALE_CONSTRANGECENTER. If sc.ScaleRangeType is set to one of these constant range types, sc.ScaleConstRange needs to be greater than 0.

Example

// Set this study to use a centered constant range scale
sc.ScaleRangeType = SCALE_CONSTRANGECENTER;
// Set the range of the scale to 10 points
sc.ScaleConstRange = 10.0f;

sc.ScaleIncrement

Type: Read/Write variable.

Initial value: 0 (auto)

sc.ScaleIncrement is the increment at which values in the right side vertical scale on the chart are displayed. This is the same as the Scale Increment setting in the Scale Window that can be opened from the Settings and Inputs tab in the Study Settings window for the study. A value of 0 means the scale increment is automatically determined by Sierra Chart.

Example

sc.ScaleIncrement = 0.01f; // Draw values on the scale at every 0.01 point

sc.ScaleRangeBottom

Read/Write variable.

Initial value: 0

sc.ScaleRangeBottom is the minimum value for the scale range when using a user-defined scale range (sc.ScaleRangeType = SCALE_USERDEFINED;). When this variable is set, it must always be less than or equal to sc.ScaleRangeTop.

Example

sc.ScaleRangeType = SCALE_USERDEFINED;

sc.ScaleRangeTop = 100.0f;
sc.ScaleRangeBottom = -100.0f;


                

sc.ScaleRangeTop

Read/Write variable.

Initial value: 0

sc.ScaleRangeTop is the maximum value for the scale range when using a user-defined scale range (sc.ScaleRangeType = SCALE_USERDEFINED;). When this variable is set, it must always be greater than or equal to sc.ScaleRangeBottom.

Example

sc.ScaleRangeType = SCALE_USERDEFINED;

sc.ScaleRangeTop = 100.0f;
sc.ScaleRangeBottom = -100.0f;

sc.ScaleRangeType

Read/Write Integer variable.

Type: Initial value: SCALE_AUTO

The sc.ScaleRangeType member allows you to get and set the vertical Scale Range Type for the study. It can be any of the following constant values:

  • SCALE_AUTO
  • SCALE_USERDEFINED
  • SCALE_INDEPENDENT
  • SCALE_SAMEASREGION
  • SCALE_CONSTRANGE
  • SCALE_CONSTRANGECENTER
  • SCALE_ZEROBASED R

Example

sc.ScaleRangeType = SCALE_INDEPENDENT; // Set this study to use an independent scale

sc.ScaleType

Read/Write variable.

Initial value: SCALE_LINEAR

sc.ScaleType is the type of value scaling that is used on the study. This can be set to either SCALE_LINEAR for a basic linear scale, or SCALE_LOGARITHMIC for a logarithmic scale.

Example

sc.ScaleType = SCALE_LOGARITHMIC; // Set this study to use a logarithmic scale

sc.ScaleValueOffset

Read/Write variable.

Initial value: 0

sc.ScaleValueOffset is a percentage value with a range from -1 to 1 for the offset of the scale from the center. A value of 1 means the graph will be pushed all the way off the bottom, and a value of -1 means the graph will be pushed all the way off the top. This is the value that gets changed when you use the Interactive Scale Move feature when you left click and drag the scale on the right side of the chart.

Example

sc.ScaleValueOffset = 0.25f

sc.ScrollToDateTime

Type: Write-only SCDateTime variable.

Initial Value: 0.

sc.ScrollToDateTime is a SCDateTime variable that can be set to a specific Date and Time to scroll the chart to.

As soon as the study function returns, the chart will scroll to the specified Date and Time and then the variable is cleared for next use, if required.

sc.SecondsPerBar

Read/Write Integer variable

sc.SecondsPerBar is the number of seconds in one bar. This is set by the Days-Mins-Secs setting in the Chart >> Chart Settings window for the chart.

For example: For a 1 Minute chart, this will be set to 60, and for a 30 Minute chart this will be set to 1800.

This variable can be changed by the study function. Any changes to this variable will not go into effect until returning from the study function. When this value is modified, the chart will be reloaded after the study function returns. The chart reload will occur before the next call into the study function.

To check if the chart bars are currently set to Days-Minutes-Seconds, use the sc.AreTimeSpecificBars() function. For sc.AreTimeSpecificBars to return an accurate result, it is necessary to call it before changing sc.SecondsPerBar.

If the Intraday chart bars are not currently time specific bars set with sc.SecondsPerBar, then the associated variable which is controlling the time period of the bars needs to be set to zero to be able to change them to time specific bars. For example, if they are based upon a specified amount of Volume, then it is necessary to set sc.VolumePerBar to zero to then be able to change them to a fixed amount of time with sc.SecondsPerBar.

Example

// Make sure this chart has no more than 30 seconds per bar
if (sc.SecondsPerBar > 30)
    sc.SecondsPerBar = 30;

sc.SelectedAlertSound

Type: Read-only Integer variable.

sc.SelectedAlertSound

Example

int SelectedAlertSound

sc.SelectedTradeAccount

Type: SCString. Read/Write Text string variable.

The sc.SelectedTradeAccount is set to the same Trade Account which is selected and displayed on the Trade Window of the chart the study is applied to. For more information, refer to Selecting Trade Account.

This can also be set to a different Trade Account to change the Trade Account for the chart. The change goes into effect when the study function returns. However, this must be set to a valid Trade Account which is also valid based upon whether Trade Simulation Mode is enabled or not. Otherwise, the new Trade Account will be ignored.

sc.ServerConnectionState

Type: Read-only Integer variable.

sc.ServerConnectionState is an Integer variable which can be one of the constants listed below. It indicates the connection state to the Data and Trade (in the case of a Trading service) servers.

The connection and disconnection to the servers is performed through File >> Connect to Data Feed and File >> Disconnect.

  • SCS_DISCONNECTED
  • SCS_CONNECTING
  • SCS_RECONNECTING
  • SCS_CONNECTED
  • SCS_CONNECTION_LOST
  • SCS_DISCONNECTING

When the connection state is disconnected and then the connection becomes connected, the study function will be called. When the connection state is connected and then it is no longer connected, the study function will be called. At either of these times the study function can check the state of the sc.ServerConnectionState variable.

sc.SetDefaults

Read-only Integer variable.

sc.SetDefaults is a TRUE (1) or FALSE (0) value that gets set to 1 (TRUE) when a study instance is manually added to a chart, a study instance is added to a chart through a Study Collection which has just been applied to a chart, or when a Chartbook is opened and the study instance is contained on a chart in the Chartbook. If the study is on more than one chart in the chartbook or there are multiple instances of it, then the study function will be called once for each instance of it, with sc.SetDefaults set to 1.

This variable is also TRUE (1) and your study function is called when the Analysis >> Studies >> Add Custom Study window is opened by a user. This is so that the Names and Descriptions of your studies can be listed for selection.

All study functions must include a code block at the top of the function that checks this member before doing any further processing within the study function. Refer to the example below. If this value is 1 (TRUE), then the study function must return at the end of the sc.SetDefaults code block.

The purpose of sc.SetDefaults is to allow the study function to configure itself and set defaults.

The codeblock for setting your configuration and defaults is not meant to be used for anything other than configuring the study and setting the defaults of the study.

What Should Be Located in the sc.SetDefaults Code Block

  • sc interface structure members that configure the study and should only be set once. An example would be sc.AutoLoop = 1. It would not make sense to set a variable like this outside of sc.SetDefaults because in some case it is too late to set them if used outside the sc.SetDefaults code block and it would be inefficient to keep setting them.
  • Setting of defaults. For example, you will want to set properties of a sc.Subgraph[] like the sc.Subgraph[].DrawStyle and the colors. You will want to set default study Input values with the sc.Input[].Set* functions. Setting of defaults must be done in the sc.SetDefaults code block because otherwise when the settings are changed through the Study Settings window for the study, those changes will get reverted back to what the study function is setting them to if the code to change the sc.Subgraph, sc.Input and other settings is done outside of the sc.SetDefaults code block.
  • sc members that need to be set only once. For example, you will want to set sc.GraphName , sc.Subgraph[].Name and sc.Input[].Name in the sc.SetDefaults code block because usually these names will not change during chart updating.

    If an sc member is associated with the chart, it must not be set in the sc.SetDefaults code block because it will have no effect. For example, you cannot set sc.StartTime1 inside of sc.SetDefaults. However, it is possible to use sc.StartTime1 from within the sc.SetDefaults code block. All ACSIL members which are related to the chart itself, like sc.StartTime1, are set and valid when sc.SetDefaults is TRUE. However, they are read-only.
  • Unless otherwise noted in the documentation for the particular ACSIL interface structure member (those that begin with sc.), any member used in the sc.SetDefaults code block can also be read, set or used outside of this code block. For example, sc.GraphName can be changed later on by also setting it outside of the sc.SetDefaults code block.
  • There are some ACSIL members like sc.BaseData[][], where it would not make sense to interact with them within the sc.SetDefaults code block because the arrays will be empty.

Example

SCSFExport scsf_UniqueFunctionName(SCStudyInterfaceRef sc)
{

    if (sc.SetDefaults)
    {
        // Set the defaults
        sc.GraphName = "My New Study Function";

        sc.Subgraph[0].Name = "Subgraph name";
        sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;

        sc.AutoLoop = 1;

        // You can also enter additional configuration code
        return;
    }

    // Perform your data processing here.

    //This is an example that multiplies the last price by 10.
    sc.Subgraph[0][sc.Index] = sc.BaseData[SC_LAST][sc.Index] * 10;

    return;
}

sc.StandardChartHeader

Read/write integer variable.

Initial value: 0 (FALSE)

If sc.StandardChartHeader is set to 1 (TRUE), then your study will use the standard main Price Graph text header. This text header can be configured by going to Global Settings >> Customize Chart Header on the menu. If you set this to 1 (TRUE), you must also set sc.DisplayAsMainPriceGraph to 1 (TRUE), otherwise it will be ignored.

Example

sc.DisplayAsMainPriceGraph = 1; // Set the study to the main Price Graph

sc.StandardChartHeader = 1; 

sc.StartTime1

Read/write integer variable.

sc.StartTime1 is the first start time for a day on the chart.

This is a time value given as the number of seconds since midnight. For more information about how this variable can be used, refer to SCDateTime.

sc.StartTime2

Read/write integer variable.

sc.StartTime2 is the second start time for a day on the chart. This is only used if sc.UseSecondStartEndTimes is set to 1 (TRUE).

This is a time value given as the number of seconds since midnight. For more information about how this variable can be used, refer to SCDateTime.

sc.StartTimeOfDay

Read-only integer variable.

sc.StartTimeOfDay is set to the starting time of the trading session for the day. This is based on the Session Times settings.

It is an integer value representing seconds since midnight. For more information, refer to SCDateTime.

It can be converted to an SCDateTime type by using SCDateTimeVariable.SetTime(sc.StartTimeOfDay).

Example

SCDateTime DT;
DT.SetTime(sc.StartTimeOfDay);

sc.StorageBlock

Read/Write block of bytes.

sc.StorageBlock is a pointer to a block of 512 bytes of permanent memory storage. This block of memory can be used for your custom data storage, and it is saved to disk when the chartbook is saved.

This storage block is unique to each individual study instance.

Depending upon what you are using the Storage Block for, you may want to enable Global Settings >> General Settings >> General 2 >> Autosave Chartbooks Time in Minutes to automatically save your Chartbook periodically.

Example

// This is the structure of our data that is to be
// stored in the storage block
struct s_PermData

{
    int Number;
    char Text[32];
};

// Here we make a pointer to the storage block as if
// it was a pointer to our structure
s_PermData* PermData;
PermData = (s_PermData*)sc.StorageBlock;

// Here we set data using the members of our structure
// This uses the memory of the storage block
PermData->Number = 10;
strcpy(PermData->Text, "Sample Text");

sc.StudyDescription

Read/Write string variable.

sc.StudyDescription is a string that can be set to a description of the study. This is optional. If you use this, it needs to be in the code block for setting your configuration and defaults. This study description will be shown in the Add Custom Study window when the study is selected.

Example

sc.StudyDescription = "Here is a description for this study. This description will be shown in the Add Custom Study window when this study is selected.";

sc.StudyGraphInstanceID

Type: Read-only Integer variable.

The StudyGraphInstanceID is a unique number assigned to each study on a chart. This identifier number is for the particular instance of your custom study which is applied to the chart. This ID number can be seen in the Chart Studies window on the right side of the study name in the Studies to Graph list.

This is the same study identifier which is used with functions like sc.GetStudyArrayUsingID.

Example

int StudyGraphInstanceID = sc.StudyGraphInstanceID;

sc.StudyRegionBottomCoordinate

Type: Read only integer variable

sc.StudyRegionBottomCoordinate is the Y-coordinate of the bottom of the region that the study is in. This value is given in the coordinate system of the client window.

This variable will only provide a valid value when read outside of the sc.SetDefaults code block. It will be set to 0 when a Chartbook is first opened and the study instance using it, is on the chart.

sc.StudyRegionTopCoordinate

Type: Read only integer variable

sc.StudyRegionTopCoordinate is the Y-coordinate of the top of the region that the study is in. This value is given in the coordinate system of the client window.

This variable will only provide a valid value when read outside of the sc.SetDefaults code block. It will be set to 0 when a Chartbook is first opened and the study instance using it, is on the chart. Although a value of 0 is the top coordinate when sc.GraphRegion = 0;

sc.StudyVersion

sc.SupportAttachedOrdersForTrading

Type: Integer variable

When sc.SupportAttachedOrdersForTrading is set to TRUE(1), then the Attached Orders set on the Trade Window for the chart the trading study is applied to will be used no matter what the Use Attached Orders setting is set to on the Trade Window.

However, this setting is irrelevant when Targets or Stops are set on the s_SCNewOrder data structure.

sc.SupportTradingScaleIn

Type: Read/Write Integer variable.

The sc.SupportTradingScaleIn variable is set to 1 when the Scaling In option for trading is enabled for the chart. 0 means it is disabled. This variable can also be set by the study function to enable Scaling In.

This variable must be set outside of and below the sc.SetDefaults code block in the study function. Otherwise, it will have no effect.

Example

sc.SupportTradingScaleIn = 1;
            

sc.SupportTradingScaleOut

Type: Read/Write Integer variable.

The sc.SupportTradingScaleOut variable is set to 1 when the Scaling Out option for trading is enabled for the chart. 0 means it is disabled. This variable can also be set by the study function to enable Scaling Out.

This variable must be set outside of and below the sc.SetDefaults code block in the study function. Otherwise, it will have no effect.

Example

sc.SupportTradingScaleOut = 1;
            

sc.Symbol

Read-only SCString variable

sc.Symbol is the symbol of the chart. To perform comparisons to this symbol, or to directly access it see How To Compare Strings and Directly Accessing a SCString, respectively.

sc.SymbolData

Type: Read-Only data structure.

sc.SymbolData is a pointer to a data structure containing all of the current pricing and related data for the symbol of the chart.

The symbol data includes market depth data, if market depth data is provided for the symbol by the Data or Trading service you are using Sierra Chart with.

The data in this structure is only valid when Sierra Chart is connected to the data feed and the symbol is receiving data from the data feed. Refer to the /ACS_Source/scsymboldata.h file in the folder that Sierra Chart is installed to for the structure definition.

To receive Market Depth data it is also necessary to set sc.UsesMarketDepthData to 1 in the study function.

For an example to access market depth data, refer to the scsf_DepthOfMarketData() function in the /ACS_Source/studies.cpp file in the folder where Sierra Chart is installed to.

sc.TextInput

Read/Write variable.

Initial value: "" (empty string)

sc.TextInput is the text input string that is made available in the study's inputs. The text input can be found at the bottom of the list of inputs shown on the Inputs and Settings tab in the Technical Study Settings window. This string can not be longer than 255 characters.

You must have the sc.TextInputName set if you want to have the text input available to the user.

Example

// Make a copy of the text input into our own c-style string. Be very careful
// when using this and make sure you will not use an invalid index into the
// string array. If this string is not used properly, the study could crash.
char TextInputCopy[256];

strncpy(TextInputCopy, sc.TextInput.GetChars(), sizeof(TextInputCopy) - 1);

sc.TextInputName

Read/Write variable.

Initial value: "" (empty string)

sc.TextInputName is a string of the name that is shown in the table of inputs on the Inputs and Settings tab in the Technical Study Settings window. You must set this to make the text input available to the user.

Example

sc.TextInputName = "Letters"; // Show the text input with the name Letters

sc.TickSize

Read/write Float Variable.

sc.TickSize is a variable that is set to the Tick Size of the chart the study instance is applied to.

This is the same as the Tick Size setting set in the Chart >> Chart Settings window.

This variable can be modified by the custom study. When it is modified, to cause the chart to reload which is necessary, the study must set sc.FlagToReloadChartData = 1.

sc.TicksPerBar / sc.NumberOfTradesPerBar

Read/Write Integer variable

sc.NumberOfTradesPerBar is the number of trade/ticks per bar setting for the chart. Changing this value will change the number of trades per bar setting on the chart.

This variable can be changed by the study function. Any changes to this variable will not go into effect until returning from the study function. When this value is modified, the chart will be reloaded after the study function returns. The chart reload will occur before the next call into the study function.

A related function is sc.AreNumberOfTradesBars() that may be useful to determine if this variable contains data that should be used in your study function.

Example

// Make sure the number of ticks per bar is at least 100
if (sc.NumberOfTradesPerBar < 100)

    sc.NumberOfTradesPerBar = 100;

sc.TitleBarName

Type: Read/Write SCString variable

The sc.TitleBarName variable is for getting and setting the Chart >> Chart Settings >> Advanced Settings 2 >> Title Bar Name setting.

This is a read/write string variable.

sc.TimeScaleAdjustment

Read-only. SCDateTime variable

sc.TimeScaleAdjustment is the difference between the Time Zone setting in Sierra Chart and GMT/UTC time. This value uses the Daylight Savings Time adjustment based upon whether it is currently in effect or not. This variable is a SCDateTime variable. You can add or subtract this variable with any SCDateTime variable.

Example


// Figure out the Date-Time of the last bar without the time offset applied.
// The Date-Time values of sc.BaseDateTimeIn[] are already adjusted to the Sierra Chart Time Zone setting.
// Subtracting sc.TimeScaleAdjustment will remove the adjustment.
SCDateTime AdjustedDateTime = sc.BaseDateTimeIn[sc.ArraySize - 1] - sc.TimeScaleAdjustment;

Example

// Adjust a time and sales record time
// TSRecord is a s_TimeAndSales record requested with sc.GetTimeAndSales().
SCDateTime TSDateTime;
TSDateTime.SetDate(TSRecord.Date);

TSDateTime.SetTimeHMS(TSRecord.Hour, TSRecord.Minute, TSRecord.Second);

TSDateTime += sc.TimeScaleAdjustment;
// TSDateTime is now adjusted to match times on the chart.

sc.TradeAndCurrentQuoteSymbol

Type: Read/Write SCString variable

sc.TradeAndCurrentQuoteSymbol is a text string containing the Trade and Current Quote Symbol set in Chart >> Chart Settings.

This symbol can be changed and one purpose for this is to change it to a Trade and Current Quote Symbol which corresponds with the sc.Symbol text string.

When this is changed, it does not go into effect until after the study function returns. At that time, the Trades List in the chart is rebuilt if necessary.

This symbol is what is used when trading from a chart. All trading related functionality uses this Trade and Current Quote symbol. Although after changing this symbol it is not possible during the same call into the the study function to then submit a trading order which will then use this symbol because the symbol has not yet gone into effect. To avoid this limitation, either wait to submit the trading order until the next call into the study function or it is necessary to use the functionality to submit an order for a different Symbol and/or Trade Account. Refer to Submitting and Managing Orders for Different Symbol and/or Trade Account.

sc.TradeServiceAccountBalance

Type: Read-only double precision float variable.

The sc.TradeServiceAccountBalance variable contains the non-simulated Cash Balance for the selected account on the Trade Window for the chart the study is applied to.

This data is provided by connected external Trading service you are using. Account balance data is not provided from all of the supported Trading services. Therefore, in many cases it will be 0. When in Sierra Chart Trade Simulation Mode, it will still indicate the Cash Balance provided by the external trading service you may be connected to.

Example

double CashBalance = sc.TradeServiceAccountBalance;

sc.TradeServiceAvailableFundsForNewPositions

Type: Read-only double precision float variable.

The sc.TradeServiceAvailableFundsForNewPositions variable contains the non-simulated Cash Balance.

Example


            

sc.TradeWindowOrderQuantity

Type: Read-only Integer variable.

sc.TradeWindowOrderQuantity is set to the order quantity on the Trade Window for the chart that your study is applied to.

Example

int OrderQuantity = sc.TradeWindowOrderQuantity;

sc.UpdateAlways

Read/Write variable.

Initial value: 0 (FALSE)

When the sc.UpdateAlways variable is set to 1 (TRUE), the study instance will update continuously rather than only when new market or order data is available for the symbol.

This means your study function will be called continuously at the update interval.

The update interval is set through Global Settings >> General Settings >> Chart Update Interval.

It is possible to set an individual chart to update at a different interval than the global Chart Update Interval. To do this, set a nonzero number for Chart >> Chart Settings >> Advanced Settings >> Chart Update Interval in Milliseconds.

One use of this setting is to simulate real time updating during testing. This setting does not affect other studies on the same chart.

To maintain efficiency, the study function will not be called more often than every 200 ms when setting this variable to TRUE and new data is not available. Otherwise, setting this variable to 1 (TRUE) could significantly increase CPU usage if the Chart Update Interval is set very low. Effective with version 1340, the preceding does not apply if the chart has set its own Chart Update Interval.

Example

sc.UpdateAlways = 1; // Set this study to continuously update

sc.UpdateStartIndex

Read variable

sc.UpdateStartIndex is only used with Manual Looping. For complete information on Manual Looping, refer to Working With Arrays and Looping.

The array indexing variables sc.Index, sc.CurrentIndex and sc.UpdateStartIndex are all set to the same value when the study function instance is called. All three of these variables can be used interchangeably. However, the behavior of sc.Index, sc.CurrentIndex and sc.UpdateStartIndex differs significantly depending whether you are using Auto Looping or Manual Looping.

sc.UpdateStartIndex is set by Sierra Chart to the index where the primary for loop in the study function will start looping from. This is the index into the sc.BaseDataIn[][] arrays where data updating has begun. This is the same index where updating should begin in the sc.Subgraph[][] arrays.

If you are creating a custom chart, sc.IsCustomChart is set to TRUE (this is very unlikely), then sc.UpdateStartIndex only refers to the index into the sc.BaseDataIn[][] arrays to begin processing at.

For example: When a chart is opened, reloaded, recalculated, or a replay is started, the study function instance will be called and sc.UpdateStartIndex will be 0. This means the study function needs to update all elements in the sc.Subgraph[].Data[] arrays it is using.

During chart updating, if there are 100 bars in a chart and a trade occurs and either the last bar is updated or a new bar is added to the chart, then sc.UpdateStartIndex variable will be set to 99 indicating the value at index 99 (bar 100) has been updated.

For example: sc.BaseDataIn[SC_LAST][99] (bar 100) has been updated. During normal chart updating sc.UpdateStartIndex will always be equal to the last index of the prior sc.ArraySize before the chart update. If a new bar was added, then there will also be a new array element at sc.BaseDataIn[][100] (bar 101). In this case, the study function needs to update the sc.Subgraph[].Data[] arrays at index 99 and index 100. The reason you need to use sc.UpdateStartIndex is to only perform calculations on the modified data and only update the study values starting from this index. This makes your study very efficient.

It is very possible that more than 1 bar will be added to a chart between updates. There could be hundreds or thousands of bars potentially added when historical data is downloaded into the chart after the initial data load from the local data file on your system. Therefore, you need to update from sc.UpdateStartIndex to the last array element in all the sc.Subgraph[][] Data arrays you are using, and not just the element at this index.

The index value provided by sc.UpdateStartIndex will never go backwards. However, during a full recalculation of the study, such as when the chart is reloaded or for other reasons, it can start back at 0. Therefore, you can rely that it will not go backwards other than to 0.

It is possible that a chart containing a study instance is making references to other charts which are triggering a full recalculation in the chart which is making the reference. In this particular case, during the full recalculation sc.UpdateStartIndex will be set to 0 for the study instances using Manual Looping. For additional information, refer to References to Other Charts and Tagging.

sc.UseGlobalChartColors

Type: Read/Write Integer variable.

When sc.UseGlobalChartColors is set to 1 or a nonzero number, then the global color settings defined in Global Settings >> Graphics Settings are used for the chart.

When sc.UseGlobalChartColors is set to 0, then the chart specific color settings defined in Chart >> Graphics Settings are used for the chart.

Example

sc.UseGlobalChartColors = 0;

sc.UseGUIAttachedOrderSetting

Read/write Integer variable.

When sc.UseGUIAttachedOrderSetting is set to a nonzero number, then the Attached Orders defined on the Trade Window for the chart, if any, will be attached to Buy Entry or Sell Entry trade orders submitted from the study function if the Use Attached Orders setting is also enabled on the Trade Window.

sc.UsePriceGraphStyle

Read/write Integer variable.

sc.UserName

Read-only Character string (SCString).

sc.UserName is the Account Name that was entered at the Sierra Chart Login window which displays when Sierra Chart starts.

sc.UseSecondStartEndTimes

Read/write integer variable.

The sc.UseSecondStartEndTimes variable can be set to 1 (TRUE) or 0 (FALSE). This is equivalent to Chart >> Chart Settings >> Use Evening Session.

When it is set to 1, then the sc.StartTime2 and sc.EndTime2 variables are used by the chart the study is on. These variables represent the Evening Session times in Chart >> Chart Settings.

sc.UsesMarketDepthData

Read/write integer variable.

The sc.UsesMarketDepthData variable when set to 1 will cause market depth data to be subscribed to for the Symbol of the chart the custom study applied to.

Sierra Chart needs to be connected to the data feed with File >> Connect to Data Feed to receive market depth data.

sc.ValueFormat

Read/Write Integer variable.

Initial value: 2.

sc.ValueFormat sets the numeric display format for all values in the sc.Subgraph[].Data arrays for the study. This can be one of the following values:

  • 0 = Zero decimal places. Example output: 1
  • 1 = One decimal place. Example output: 0.1
  • 2 = Two decimal places. Example output: 0.01
  • 3 = Three decimal places. Example output: 0.001
  • 4 = Four decimal places. Example output: 0.0001
  • 5 = Five decimal places. Example output: 0.00001
  • 6 = Six decimal places. Example output: 0.000001
  • 20 = Time value. Where the value is in Microsoft Date-Time Variant format. Example output: 12:30:00
  • VALUEFORMAT_INHERITED = Same Value Format as is set in Chart >> Chart Settings .
  • 102 = Halves. Example output: 1/2
  • 104 = Quarters. Example output: 1/4
  • 108 = Eighths. Example output: 1/8
  • 116 = Sixteenths. Example output: 1/16
  • 132 = Thirty-seconds. Example output: 1/32
  • 164 = Sixty-fourths. Example output: 1/64
  • 228 = One-hundred-twenty-eighths. Example output: 1/128
  • 356 = Two-hundred-fifty-sixths. Example output: 1/256

This value is overridden and set to VALUEFORMAT_INHERITED if the study is set to sc.GraphRegion = 0. If this is not the desired outcome, the solution to this is to set sc.ValueFormat outside of the SC.SetDefaults code block. However, if it is set outside of this code block, it cannot be changed by the user.

Example

sc.ValueFormat = 4;

sc.ValueIncrementPerBar

Type: Read-only float variable.

sc.ValueIncrementPerBar is the Value Increment Per Bar in Ticks setting in Chart >> Chart Settings >> Advanced Settings 2.

For complete details, refer to Value Increment Per Bar in Ticks in the Chart Settings documentation.

Example

float ValueIncrementPerBar = sc.ValueIncrementPerBar;

sc.VersionNumber

Read string variable

sc.VersionNumber is a string containing the current version number of Sierra Chart the user is using. Note: If your Advanced Custom Study is used on a version of Sierra Chart that does not support all of the interface members compared with the version it was built under, then a warning message will be given and the study cannot be used. Therefore, using this version number member to perform a check to see if your study will work on a certain version, is unnecessary.

Example

if (atoi(sc.VersionNumber) < 145)
{

    //do something
}

sc.VolumeAtPriceForBars

Type: Read-only custom data array object of type c_VAPContainer.

Sierra Chart internally maintains volume at price data for each price tick of each loaded bar, based upon the Tick Size setting for the chart. This data is maintained when sc.MaintainVolumeAtPriceData is set to 1 (TRUE) in your custom study function. Or, when there is a study on the chart which requires this data such as the Volume by Price study. This data is fully accessible through the ACSIL using the member sc.VolumeAtPriceForBars.

This member has been changed in version 834. Code developed before this version will need to be modified. Unlike with Sierra Chart versions prior 834, you do not need to use Visual C++ when using sc.VolumeAtPriceForBars or any specific Visual C++ version. Using the Sierra Chart built-in compiler is fine.

For an example on how to use sc.VolumeAtPriceForBars, refer to the function scsf_VolumeAtPriceArrayTest in the /ACS_Source/studies8.cpp file in the in the folder where Sierra Chart is installed to. And refer to scsf_VolumeWeightedAveragePrice in studies2.cpp. The basic premise is to use the VAP container member function GetNextHigherVAPElement to walk thru the VAP data for each price value for the specified bar index. There are other methods in the c_VAPContainer object as well that can be used.

sc.VolumePerBar

Read/Write Integer variable.

sc.VolumePerBar is the Volume per bar setting for the chart. Changing this value will change the Volume Per Bar setting on the chart.

This variable can be changed by the study function. Any changes to this variable will not go into effect until returning from the study function. When this value is modified, the chart will be reloaded after the study function returns. The chart reload will occur before the next call into the study function.

To check if the chart bars are currently set to Volume Per Bar, use the sc.AreVolumeBars function. This must be done before changing this variable for this function to return an accurate result.

Example

// Make sure the volume per bar is at least 500
if (sc.VolumePerBar < 500)

    sc.VolumePerBar = 500;

*Last modified Wednesday, 14th September, 2016.