Pine script – function returns values

//@version=4
study(“COT weekly change (makuchaku)”)
isCommodity = true
symbol = “xx”

float oi = na
float asset_mgr = na

cot_data_financials(symbol) =>
oi = 1
asset_mgr = 2
[oi, asset_mgr]

cot_data_commodities(symbol) =>
oi = 3
asset_mgr = 4
[oi, asset_mgr]

// [oi, asset_mgr] = (isCommodity ? cot_data_financials(symbol) : cot_data_commodities(symbol))
if isCommodity
[_oi, _asset_mgr] = cot_data_commodities(symbol)
oi := _oi
asset_mgr := _asset_mgr
else
[_oi, _asset_mgr] = cot_data_financials(symbol)
oi := _oi
asset_mgr := _asset_mgr

plot(oi) // plots 3
plot(asset_mgr) // plots 4

This entry was posted in Uncategorized. Bookmark the permalink.