once_per_bar

Syntax

declare once_per_bar;

Description

Changes the recalculation mode of a study. By default, last study values are recalculated after each tick. If this declaration is applied, the study is forced to recalculate the last values only once per bar. This declaration can be used to reduce CPU usage for studies which do not need to be recalculated per each tick.

Example

declare once_per_bar;
input time = 0930;
AddVerticalLine(secondsFromTime(time)[1] < 0 && secondsFromTime(time) >= 0, time);

This study plots a vertical line between the bars created before and after the specified time in the EST time zone. Since the creation time for bars is fixed, there is no need to recalculate the study after each tick.