[ASK] Grab Heikin Ashi value for calculation
Posted: Thu Feb 10, 2022 3:38 am
I try to get value from HA for used in n1 , n2 and n3 calculation. Do I need to make another security request for each of it?
Code: Select all
//--------------
// Sources:
src0 = open
src1 = high
src2 = low
src3 = close
src4 = hl2
src5 = hlc3
src6 = ohlc4
src7 = ta.tr
vol = volume
// Input Settings
PHX_TF = input.timeframe ('', 'PHX TimeFrame',inline='phx_L1', group = groupPHX)
PHX_Repaint = input (false, 'Repainting', inline='phx_L1', group = groupPHX)
PHX_Use_HA = input (true, 'Heikin Ashi', inline='phx_L1', group = groupPHX)
PHX_src = input (close, "Source", inline='phx_L1', group = groupPHX)
n1 = input(9, 'Phx master', group = groupPHX)
n2 = input(6, 'Phx time 1', group = groupPHX)
n3 = input(3, 'Phx time 2', group = groupPHX)
PHX_security = request.security (PHX_Use_HA?ticker.heikinashi(syminfo.tickerid):syminfo.tickerid, PHX_TF, PHX_src[PHX_Repaint?0:barstate.isrealtime?1:0])[PHX_Repaint?0:barstate.isrealtime?0:1]
// Calculate n1 , n2, n3 below from HA data above
tci(src) =>
ta.ema((src - ta.ema(src, n1)) / (0.025 * ta.ema(math.abs(src - ta.ema(src, n1)), n1)), n2) + 50
csi(src) =>
math.avg(ta.rsi(src, n3), ta.tsi(src0, n1, n2) * 50 + 50)
// END OF SECTION
//--------------------------