request.security_lower_tf отображается не как задумано

Отображение в одном окне, данных индикатора текущего тф и на 4 порядка ниже.

Вместо отображения меньшего тф получаем отображение графика цены, тоесть если сравним с отображением индикатора 4 порядка ниже, то картинка кардинально разная.

Что хочу получить: чтобы к примеру , на графике D1 индикатор c периодом H4 отображался аналогично H4.

//@version=5
indicator(title="Awesome Oscillator for lower timeframe", shorttitle="AOE")



smma(src, length) =>
    sma = ta.sma(src, length)
    smma =  0.0
    smma := na(smma[1]) ? sma : (smma[1] * (length - 1) + src) / length
    smma

ma(source, length, type) =>
    switch type
        "SMA" => ta.sma(source, length)
        "SMMA" => smma(source, length)
        "EMA" => ta.ema(source, length)
        "RMA" => ta.rma(source, length)
        "WMA" => ta.wma(source, length)
        "VWMA" => ta.vwma(source, length)



// Awesome Oscillator
aoType = input.string(title = "Method", defval = "SMA", options=["SMA", "SMMA", "EMA", "RMA", "WMA", "VWMA"], group="Awesome Oscillator (Fast Line - Slow Line)")
fastAoLength = input.int(title = "Fast Line Length", defval = 5, minval = 1, maxval = 233, group="Awesome Oscillator (Fast Line - Slow Line)")
slowAoLength = input.int(title = "Slow Line Length", defval = 34, minval = 1, maxval = 233, group="Awesome Oscillator (Fast Line - Slow Line)")
aoSrc = input(hl2, title="Source", group="Awesome Oscillator (Fast Line - Slow Line)")

ao = ma(aoSrc, fastAoLength, aoType) - ma(aoSrc, slowAoLength, aoType)
diff = ao - ao[1] 
plot(ao, color = diff <= 0 ? #F44336 : #009688, style=plot.style_histogram,linewidth = 3)
changeToGreen = ta.crossover(diff, 0)
changeToRed = ta.crossunder(diff, 0)

// Moving Average Line
maType = input.string(title = "Method", defval = "SMA", options=["SMA", "SMMA", "EMA", "RMA", "WMA", "VWMA"], group="Moving Average Line (Fast Line - Slow Line)")
fastMaLength = input.int(title = "Fast Line Length", defval = 5, minval = 1, maxval = 233, group="Moving Average Line (Fast Line - Slow Line)")
slowMaLength = input.int(title = "Slow Line Length", defval = 34, minval = 1, maxval = 233, group="Moving Average Line (Fast Line - Slow Line)")
smoothingMa = input.int(title = "Smoothing Length", defval = 0, minval = 0, maxval = 233, group="Moving Average Line (Fast Line - Slow Line)")
maSrc = input(hl2, title="Source", group="Moving Average Line (Fast Line - Slow Line)")
displayLowerTf = input.bool(true, title="Display lower timeframe", group="Moving Average Line (Fast Line - Slow Line)", tooltip='If the values of the MA line settings (method, length and source) are equal to the values of the AO settings, then instead of the MA line the AO lines for the lower timeframe will be displayed: if the chart timeframe is one month, then the lower timeframe will be one week; if the chart timeframe is "W", then the lower timeframe will be "D"; if the chart timeframe is "D", then the lower timeframe will be "4h"; if the chart timeframe is "4h", then the lower timeframe will be "1h" (240 / 4 = 60 minutes); if the chart timeframe is "1h", then the lower timeframe will be "15m"; if the chart timeframe is "15m", then the lower timeframe will be "4m" (15 / 4 ≈ 4).')

maLine = ma(maSrc, fastMaLength, maType) - ma(maSrc, slowMaLength, maType)

lowerTf = str.tostring(timeframe.in_seconds(timeframe.period) > 300 ? timeframe.from_seconds(math.round(timeframe.in_seconds(timeframe.period) / (timeframe.ismonthly ? 4.35 : (timeframe.isweekly ? 7 : (timeframe.isdaily ? 6 : 4))))) : "1")

float[] lowerMaLine = (maType == aoType and fastMaLength == fastAoLength and slowMaLength == slowAoLength and smoothingMa == 0 and maSrc == aoSrc) ? request.security_lower_tf(syminfo.tickerid, lowerTf, maLine) : na

lowerMaLineLength = na(lowerMaLine) == false ? array.size(lowerMaLine) : 0

if (lowerMaLineLength > 0)
    maLine := nz(array.get(lowerMaLine, lowerMaLineLength - 1))

var lowerTfLabel = label.new(na, na, "", color=color.new(color.blue, 100), style=label.style_label_left, textcolor=#2962ff, size=size.small, tooltip="Lower timeframe")

if (barstate.islast and displayLowerTf and lowerMaLineLength > 0)
    label.set_xy(lowerTfLabel, bar_index + 1, maLine)
    label.set_text(lowerTfLabel, lowerTf)

maLineDiff = maLine - maLine[1] 


if smoothingMa > 0
    maLine := ma(maLine, smoothingMa, maType)

plot(maLine, color=maLineDiff <= 0 ? color.blue : color.blue, style=plot.style_stepline, linewidth=2, title="MA Line")

Ответы (0 шт):