Changes

Jump to navigation Jump to search

How Scripts Work

656 bytes removed, 12:28, 27 March 2019
When a value of a bar '''N''' bars ago is referenced in a script, the study can only be visualized starting with the '''N + 1''' bar.
The number of previous bars that must be available for a script in order to start performing calculations is called '''Maximum number of bars a study will reference''', or '''MaxBarsBack'''. The '''MaxBarsBack''' value can for the signals should be selected to be detected automatically or set manually.
When detected automatically, '''MaxBarsBack '''will initially be set to the value of the largest data offset in the study; however, if a variable data offset is used in the script, the initial '''MaxBarsBack ''' value may prove to be too small.  In such a case, the '''MaxBarsBack '''value will automatically be increased by 5 or by a factor of 1.618, whichever yields a higher value, and the study recalculated. The process of automatic '''MaxBarsBack '''detection may cause some functions to be executed repeatedly for the first few bars of a chart when a study is first applied; this can be avoided by setting the '''MaxBarsBack ''' value manually. To select the smallest '''MaxBarsBack '''value sufficient for a particular studystrategy, set the value manually. The recommended initial '''MaxBarsBack '''value is 50to the largest data offset across all signals applied to a given chart.
Learn more about setting '''MaxBarsBack''' values for [[Strategy_Properties|Signals]]
<br>
 
=== Order Execution Priority ===

Navigation menu