CVR
CVR

Reputation: 1

First 5 min candle OHLC with valuewhen

I am using below lines of code to get first 5 min candle HLOC and it is working correctly. Is there any better way of doing this? I want to reduce security function calls.

is_newbar(res) => change(time(res)) != 0

hl_5minFunc(sx) =>

h_5 = security(sx,'5', valuewhen(is_newbar('D'),high,0))

l_5 =security(sx, '5', valuewhen(is_newbar('D'),low,0))

o_5 = security(sx,'5', valuewhen(is_newbar('D'),open,0))

c_5 =security(sx,'5', valuewhen(is_newbar('D'),close,0))

[o_5, h_5, l_5,c_5]

//First Bar (5Min) of the day HLOC

[fopen_1,fhigh_1, flow_1, fclose_1] = security(syminfo.tickerid,"5", hl_5minFunc(syminfo.tickerid))

Upvotes: 0

Views: 766

Answers (1)

rumpypumpydumpy
rumpypumpydumpy

Reputation: 3833

is_newbar(res) => change(time(res)) != 0

[fopen_1,fhigh_1, flow_1, fclose_1] = security(syminfo.tickerid, "5", [valuewhen(is_newbar('D'), high, 0), valuewhen(is_newbar('D'), low, 0),valuewhen(is_newbar('D'), open, 0), valuewhen(is_newbar('D'), close, 0)])

Upvotes: 1

Related Questions