Reputation: 834
I can't find nor understand the funcion na()
in pinescript. In the example below, the script prints a Heikin Ashi OHLC bars for a specific custom timeframe
//@version=4
strategy("[⚡TC⚡] Heikin Ashi Timeframes", overlay=false)
higherRes =input(title="Time 1", type=input.string, defval="90")
is_newbar(res) =>
t = time(res)
not na(t) and (na(t[1]) or t > t[1])
o = security(syminfo.tickerid, higherRes, open)
h = security(syminfo.tickerid, higherRes, high)
l = security(syminfo.tickerid, higherRes, low)
c = security(syminfo.tickerid, higherRes, close)
Upvotes: 1
Views: 8585
Reputation: 159114
If you read the documentation, you will find section "Preventing na
values, functions na
and nz
" describing its purpose:
In addition, there is a simple function with one argument that returns a logical result called
na
. This function makes it possible to check if the argument isna
or not. Check it out here.
The link is a description of the function:
na
Test value if it's a NaN.
na(x) → bool
na(x) → series[bool]
Returns
true if x is not a valid number (x is NaN), otherwise false.
See also
Upvotes: 2