Alex
Alex

Reputation: 115

Condition an OHLCV 'request.security' call

To condition a request.security call, you can use the ? operator, like this:

C = 1 > 0 ? request.security(syminfo.tickerid, "D", close) : 0

But is there any way to condition an OHLCV request.security call?

I'm encountering a Syntax error at input '[' error with this array format:

[O, H, L, C, V] = 1 > 0 ? request.security(syminfo.tickerid, "D", [open, high, low, close, volume]) : [0, 0, 0, 0, 0]

Upvotes: 0

Views: 35

Answers (1)

vitruvius
vitruvius

Reputation: 21111

That is not possible.

You cannot do something like below:

[a, b, c, d] = [open, close, high, low]

As a workaround, you can do:

[O_htf, H_htf, L_htf, C_htf, V_htf] = request.security(syminfo.tickerid, "D", [open, high, low, close, volume])

O = (1 > 0) ? O_htf : 0
H = (1 > 0) ? H_htf : 0
L = (1 > 0) ? L_htf : 0
C = (1 > 0) ? C_htf : 0
V = (1 > 0) ? V_htf : 0

Upvotes: 0

Related Questions