How Can We Help?

CONDREF Function

You are here:
< All Topics

Store or lock in the latest value when the condition is met.

Syntax:
CONDREF(Value if true, True Condition)
or
CONDREF(Value if true, True Condition, Source Value if reset, Reset Condition)

set SMA30 = SMA(close,30)
set BuyAmount = CONDREF(Close, Close > SMA30)

or

set SMA30 = SMA(close,30)
set BuyAmount = CONDREF(Close, Close > SMA30, 0 , Close < SMA30)

–Closing Price––Condition 1––Condition 2––Condref Value–
20TrueFalse20
23TrueFalse23
21TrueFalse21
25FalseTrue0
26FalseFalse0
27.5TrueFalse27.5
32TrueFalse32

BuyAmount will be equal to the most recent close if the closing price is more than the SMA. If in the next period the condition is still true, then the value will be replaced by the new closing price. This will continue until the closing price is no longer more than the SMA, and the function will reset the BuyAmount back to zero.

Table of Contents