Security() Function

Author: Optuma Team Last updated: Aug 16, 2020 04:28


When you have a number of tools applied to the chart, and tools applied to other tools, it can be difficult to ensure that a tool is basing its calculations off of the chart data, and not another indicator or overlay.

The SECURITY() function is designed to help in these situations by returning the primary security data of the chart. This is useful when (for example) applying a ShowBar, ShowView or ShowPlot on a tool or an overlay plot. (eg. applying a Show Bar on a Volume tool) but wanting the scripts to use the charts data.

In this example…

Close() > MA()


The Show View (shaded green zones) the Close() is actually using the volume and the MA() is the average of the volume. If you were wanting to show the charts close being higher than the MA but have the result displayed within the volume window, you can now use the following script:

// Using Security() to access directly to the chart data.
Data1 = Security();
// This returns positive signal when the Close price is greater than the average of the chart.
Close(Data1) > MA(Data1)

This will ensure the data is coming from the chart, not the volume.