← К каталогу
Исходный код · ID 3704

atai_volume_pressure_analyzer_v_1_0_—_pure_up_down@lifeindreamsworld_6215428748079012230.txt

Похожие материалы по тегам

ea robofibo source v.11.2.mq4MetaTrader 4 · 1 общих теговᴇɴᴛʀʏ.txtTradingView · 1 общих теговzonestrategy.mqhMetaTrader 5 · 1 общих теговxauusd_simple_strategy7.mq4MetaTrader 4 · 1 общих теговxauusd_grok_presisi_scalper_v1.4 - anti detach.mq5MetaTrader 5 · 1 общих теговxauusd_gold_perfect.mq4MetaTrader 4 · 1 общих тегов
Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Получить полный код

Поиск по коду файла

indicator(title = "ATAI Volume Pressure Analyzer V 1.1 — Pure Up/Down", shorttitle = "ATAI.VPA", overlay = true, max_bars_back=500 )

string groupGlobal = "① Global Settings"
P = input.int(
     defval = 55,
     title = "Global Period (bars)",
     minval = 1,
     tooltip = "Lookback length for host-TF volume MAs and segment KPIs.",
     group = groupGlobal
 )

string groupTf = "② Timeframes"
lowerTimeframeTooltip = "The indicator scans lower timeframe data to approximate up and down volume. By default, the timeframe is chosen automatically. These inputs override this with a custom timeframe. Higher timeframes provide more historical data, but the data will be less precise."
useCustomTf  = input.bool(false, "Use custom timeframe", tooltip = lowerTimeframeTooltip, group = groupTf)
lowerTfInput = input.timeframe("1", "Timeframe", group = groupTf)

string lowerTf = switch
    useCustomTf         => lowerTfInput
    timeframe.isseconds => "1S"
    timeframe.isintraday=> "1"
    timeframe.isdaily   => "5"
    => "60"

import TradingView/ta/10 as tvta
[upVolume, downVolume, delta] = tvta.requestUpAndDownVolume(lowerTf)
float TF_buy   = math.abs(upVolume)
float TF_sell  = math.abs(downVolume)
float TF_tot   = TF_buy + TF_sell
float TF_delta = TF_buy - TF_sell

float TF_buy_SMA  = ta.sma(TF_buy,  P)
float TF_sell_SMA = ta.sma(TF_sell, P)

int iB_kpi = int(math.floor((P - 1) / 2.0))
int iC_kpi = P - 1

int   len_AtoB_kpi   = math.max(iB_kpi, 0)
float AtoB_buy_kpi   = len_AtoB_kpi > 0 ? math.sum(TF_buy,  len_AtoB_kpi)  : na
float AtoB_sell_kpi  = len_AtoB_kpi > 0 ? math.sum(TF_sell, len_AtoB_kpi)  : na
float AtoB_delta_kpi = AtoB_buy_kpi - AtoB_sell_kpi

float sumBuy_0_iC_kpi  = math.sum(TF_buy,  iC_kpi + 1)
float sumBuy_0_iB_kpi  = math.sum(TF_buy,  iB_kpi + 1)
float sumSell_0_iC_kpi = math.sum(TF_sell, iC_kpi + 1)
float sumSell_0_iB_kpi = math.sum(TF_sell, iB_kpi + 1)

float CtoB_buy_kpi   = sumBuy_0_iC_kpi  - sumBuy_0_iB_kpi
float CtoB_sell_kpi  = sumSell_0_iC_kpi - sumSell_0_iB_kpi
float CtoB_delta_kpi = CtoB_buy_kpi - CtoB_sell_kpi

f_fmt(float val) =>
    if na(val)
        "—"
    else
        string sign = val < 0 ? "-" : val > 0 ? "+" : ""
        float  av   = math.abs(val)
        sign + (
             av >= 1e9 ? str.format("{0,number,0.##}B", av/1e9) :
             av >= 1e6 ? str.format("{0,number,0.##}M", av/1e6) :
             av >= 1e3 ? str.format("{0,number,0.##}K", av/1e3) :
                         str.format("{0,number,0}",    av))

f_hostTfLabel() =>
    float n = str.tonumber(timeframe.period)
    not na(n) ? (str.tostring(int(n)) + "Min") :
     timeframe.period == "D" ? "1D" :
     timeframe.period == "W" ? "1W" :
     timeframe.period == "M" ? "1M" : timeframe.period

f_blockAmounts(string title, float up, float dn, float delta) =>
    title + "\n" +
     "↑ " + f_fmt(up) + "\n" +
     "↓ " + f_fmt(dn) + "\n" +
     "Δ " + f_fmt(delta)

f_blockMAsSum(string title, float upMA, float dnMA, float total) =>
    title + "\n" +
     "Σ "   + f_fmt(total) + "\n" +
     "MA ↑ " + f_fmt(upMA) + "\n" +
     "MA ↓ " + f_fmt(dnMA)

f_blockAmountsWithTotal(string title, float total, float up, float dn, float delta) =>
    title + "\n" +
     "Σ " + f_fmt(total) + "\n" +
     "↑ " + f_fmt(up) + "\n" +
     "↓ " + f_fmt(dn) + "\n" +
     "Δ " + f_fmt(delta)

f_blockMAsOnly(string title, float upMA, float dnMA) =>
    title + "\n" +
     "MA ↑ " + f_fmt(upMA) + "\n" +
     "MA ↓ " + f_fmt(dnMA)

string groupColors = "③ Colors"
baseColor = input.color(
     defval = #6abaff,
     title = "Primary color",
     tooltip = "Unified color for all HUD/table elements.",
     group = groupColors)
negColor  = input.color(
     defval = #ff5076,
     title = "Negative color",
     tooltip = "Used ONLY when a block's Δ is negative.",
     group = groupColors)
panelBG   = color.new(baseColor, 95)
borderCol = color.new(baseColor, 0)
textCol   = baseColor

const int COLS = 4
const int ROWS = 5
var table hud = na
if na(hud)
    hud := table.new(position.bottom_right, COLS, ROWS, frame_color = borderCol, border_color = borderCol, frame_width = 1, border_width = 1)

f_paintBox(int col, int row, string txt, float keyDelta) =>
    color tcl = not na(keyDelta) and keyDelta < 0 ? negColor : textCol
    table.cell(hud, col, row, txt, text_color = tcl, bgcolor = panelBG, text_size = size.small, text_halign = text.align_left)

if barstate.islast

    table.cell(hud, 0, 0, "Vol.Analyzer", text_color=textCol, bgcolor=panelBG, text_size=size.small, text_halign=text.align_left)
    table.cell(hud, 1, 0, "Length = " + str.tostring(P), text_color=textCol, bgcolor=panelBG, text_size=size.small, text_halign=text.align_left)
    table.cell(hud, 2, 0, "Lower TF: " + lowerTf, text_color=textCol, bgcolor=panelBG, text_size=size.small, text_halign=text.align_left)
    table.cell(hud, 3, 0, "Host TF: " + f_hostTfLabel(), text_color=textCol, bgcolor=panelBG, text_size=size.small, text_halign=text.align_left)

    string hostLbl = f_hostTfLabel()

    f_paintBox(0, 1, f_blockAmountsWithTotal(hostLbl, TF_tot, TF_buy, TF_sell, TF_delta), TF_delta)

    f_paintBox(1, 1, f_blockMAsOnly(hostLbl + " MA", TF_buy_SMA, TF_sell_SMA), TF_delta)   
    f_paintBox(2, 1, f_blockAmounts("C→B", CtoB_buy_kpi, CtoB_sell_kpi, CtoB_delta_kpi), CtoB_delta_kpi)
    f_paintBox(3, 1, f_blockAmounts("B→A", AtoB_buy_kpi, AtoB_sell_kpi, AtoB_delta_kpi), AtoB_delta_kpi)

    for r = 2 to ROWS - 1
        for c = 0 to COLS - 1
            bool reserved = (r == 2 and (c == 0 or c == 1)) or (r == 1 and (c == 0 or c == 1)) or (r == 0)
            if not reserved
                table.cell(hud, c, r, "", text_color=textCol, bgcolor=panelBG, text_size=size.small, text_halign=text.align_left)

string groupOffset_wing     = "? Wing Offset"
bool   useOffset_wing       = input.bool(false, "Use wing offset", tooltip = "Shift wing drawing forward by a specified number of bars.", group = groupOffset_wing)
int    offsetBars_wing      = input.int(3, "Offset (bars)", minval = 0, tooltip = "Number of bars to shift the wing drawing forward. Set to 0 to disable.", group = groupOffset_wing)
float  offsetStdMul_wing    = input.float(1, "Offset std deviation multiplier", minval = 0.0, tooltip = "Multiplier for standard deviation when estimating future A points (default Fibonacci 27.2%).", group = groupOffset_wing)

int   iB_wing = int(math.floor((P - 1) / 2.0))
int   iC_wing = P - 1

int   x_A_wing = bar_index
int   x_B_wing = bar_index - iB_wing
int   x_C_wing = bar_index - iC_wing

float y_A_top_wing = high
float y_A_bot_wing = low

float y_B_top_wing = useOffset_wing ? (iB_wing > offsetBars_wing ? high[iB_wing - offsetBars_wing] : na) : high[iB_wing]
float y_B_bot_wing = useOffset_wing ? (iB_wing > offsetBars_wing ? low[iB_wing  - offsetBars_wing] : na) : low[iB_wing]
float y_C_top_wing = useOffset_wing ? (iC_wing > offsetBars_wing ? high[iC_wing - offsetBars_wing] : na) : high[iC_wing]
float y_C_bot_wing = useOffset_wing ? (iC_wing > offsetBars_wing ? low[iC_wing  - offsetBars_wing] : na) : low[iC_wing]

bool  haveLeftWing  = bar_index >= iC_wing and iC_wing > iB_wing
bool  haveRightWing = bar_index >= iB_wing and iB_wing > 0

string groupNorm_wing = "④ Wing Normalization"
bool   linkAtrToP_wing  = input.bool(true, "Link ATR length to P", tooltip = "If ON, normalization uses ATR(P). If OFF, the explicit length below is used.", group = groupNorm_wing)
int    atrLenInput_wing = input.int(55, "ATR length (override)", minval = 1, tooltip = "Used only when 'Link ATR length to P' is OFF.", group = groupNorm_wing)
int    atrLen_wing      = linkAtrToP_wing ? P : atrLenInput_wing
float  atr_wing         = ta.atr(atrLen_wing)
float  atr_safe_wing    = math.max(atr_wing, syminfo.mintick)  // avoid division by near-zero

_slope_norm_wing(y2, y1, dxBars, atrVal) => dxBars <= 0 or atrVal <= 0 ? na : ((y2 - y1) / dxBars) / atrVal
_deg_from_slope_norm_wing(s) => na(s) ? na : math.atan(s) * 180.0 / math.pi

float dx_CB_wing = float(iC_wing - iB_wing) // bars between C and B
float slopeN_CB_top_wing = haveLeftWing  ? _slope_norm_wing(y_B_top_wing, y_C_top_wing, dx_CB_wing, atr_safe_wing) : na
float slopeN_CB_bot_wing = haveLeftWing  ? _slope_norm_wing(y_B_bot_wing, y_C_bot_wing, dx_CB_wing, atr_safe_wing) : na
float angDegN_CB_top_wing = _deg_from_slope_norm_wing(slopeN_CB_top_wing)
float angDegN_CB_bot_wing = _deg_from_slope_norm_wing(slopeN_CB_bot_wing)

float dx_BA_wing = float(iB_wing) // bars between B and A (A = current)
float slopeN_BA_top_wing = haveRightWing ? _slope_norm_wing(y_A_top_wing, y_B_top_wing, dx_BA_wing, atr_safe_wing) : na
float slopeN_BA_bot_wing = haveRightWing ? _slope_norm_wing(y_A_bot_wing, y_B_bot_wing, dx_BA_wing, atr_safe_wing) : na
float angDegN_BA_top_wing = _deg_from_slope_norm_wing(slopeN_BA_top_wing)
float angDegN_BA_bot_wing = _deg_from_slope_norm_wing(slopeN_BA_bot_wing)

_fmt_deg_wing(x) => na(x) ? "—" : (str.tostring(x, "#.0") + "°")

string groupColors_wing = "⑤ Wing Colors"
int   fillTrans_wing = input.int(90, "Fill transparency (0-100)", minval = 0, maxval = 100,
     tooltip = "Higher value = more transparent.", group = groupColors_wing)

var color runtimeLeftColor_wing  = na
var color runtimeRightColor_wing = na

var color activeLeftColor_wing  = na
var color activeRightColor_wing = na

int nearZeroDeg_wing = input.int(3, "Near-zero threshold (deg)", minval = 0, maxval = 30,
     tooltip = "Angles with |deg| below this are neutral (gray) in both HUD and wings.", group = groupColors_wing)

_hud_angle_text_color_wing(ang) =>
    na(ang) ? color.new(textCol, 60) : math.abs(ang) < nearZeroDeg_wing ? #8a8a8acc : (ang > 0 ? textCol : negColor)

_wing_color_from_fonts_wing(angTop, angBot) =>
    cTop = _hud_angle_text_color_wing(angTop)
    cBot = _hud_angle_text_color_wing(angBot)
    cTop == cBot ? cTop : color.gray

runtimeLeftColor_wing  := _wing_color_from_fonts_wing(angDegN_CB_top_wing, angDegN_CB_bot_wing)
runtimeRightColor_wing := _wing_color_from_fonts_wing(angDegN_BA_top_wing, angDegN_BA_bot_wing)

activeLeftColor_wing  := runtimeLeftColor_wing
activeRightColor_wing := runtimeRightColor_wing

int x_C_draw_wing = x_C_wing + (useOffset_wing ? offsetBars_wing : 0)
int x_B_draw_wing = x_B_wing + (useOffset_wing ? offsetBars_wing : 0)
int x_A_draw_wing = x_A_wing + (useOffset_wing ? offsetBars_wing : 0)

int len_top_pred_wing = iC_wing + 1
int len_bot_pred_wing = iB_wing + 1

float meanHigh = ta.sma(high, len_top_pred_wing)
float stdHigh  = ta.stdev(high, len_top_pred_wing)

float meanLow  = ta.sma(low,  len_bot_pred_wing)
float stdLow   = ta.stdev(low, len_bot_pred_wing)

float y_A_top_pred_wing = not na(meanHigh) and not na(stdHigh) ? (meanHigh + offsetStdMul_wing * stdHigh) : na
float y_A_bot_pred_wing = not na(meanLow)  and not na(stdLow)  ? (meanLow  - offsetStdMul_wing * stdLow)  : na

float y_A_top_draw_wing = useOffset_wing ? y_A_top_pred_wing : y_A_top_wing
float y_A_bot_draw_wing = useOffset_wing ? y_A_bot_pred_wing : y_A_bot_wing

var line     ln_CB_top_wing = na
var line     ln_CB_bot_wing = na
var line     ln_BA_top_wing = na
var line     ln_BA_bot_wing = na
var linefill lf_CB_wing     = na
var linefill lf_BA_wing     = na

if haveLeftWing
    if na(ln_CB_top_wing)
        ln_CB_top_wing := line.new(
         x1 = (useOffset_wing ? x_C_draw_wing : x_C_wing), 
         y1 = y_C_top_wing, 
         x2 = (useOffset_wing ? x_B_draw_wing : x_B_wing), 
         y2 = y_B_top_wing, 
         xloc = xloc.bar_index, 
         extend = extend.none, 
         width = 1, 
         color = activeLeftColor_wing )
    else
        line.set_xy1(ln_CB_top_wing, (useOffset_wing ? x_C_draw_wing : x_C_wing), y_C_top_wing)
        line.set_xy2(ln_CB_top_wing, (useOffset_wing ? x_B_draw_wing : x_B_wing), y_B_top_wing)
        line.set_color(ln_CB_top_wing, activeLeftColor_wing)

    if na(ln_CB_bot_wing)
        ln_CB_bot_wing := line.new(
         x1 = (useOffset_wing ? x_C_draw_wing : x_C_wing),
         y1 = y_C_bot_wing,
         x2 = (useOffset_wing ? x_B_draw_wing : x_B_wing),
         y2 = y_B_bot_wing,
         xloc = xloc.bar_index,
         extend = extend.none,
         width = 1,
         color = activeLeftColor_wing    )
    else
        line.set_xy1(ln_CB_bot_wing, (useOffset_wing ? x_C_draw_wing : x_C_wing), y_C_bot_wing)
        line.set_xy2(ln_CB_bot_wing, (useOffset_wing ? x_B_draw_wing : x_B_wing), y_B_bot_wing)
        line.set_color(ln_CB_bot_wing, activeLeftColor_wing)

    if not na(lf_CB_wing)
        linefill.delete(lf_CB_wing)
    lf_CB_wing := linefill.new(ln_CB_top_wing, ln_CB_bot_wing, color = color.new(activeLeftColor_wing, fillTrans_wing))

if haveRightWing
    if na(ln_BA_top_wing)
        ln_BA_top_wing := line.new(
         x1 = (useOffset_wing ? x_B_draw_wing : x_B_wing), 
         y1 = y_B_top_wing, 
         x2 = (useOffset_wing ? x_A_draw_wing : x_A_wing), 
         y2 = (useOffset_wing ? y_A_top_draw_wing : y_A_top_wing), 
         xloc = xloc.bar_index, 
         extend = extend.none, 
         width = 1, 
         color = activeRightColor_wing  )
    else
        line.set_xy1(ln_BA_top_wing, (useOffset_wing ? x_B_draw_wing : x_B_wing), y_B_top_wing)
        line.set_xy2(ln_BA_top_wing, (useOffset_wing ? x_A_draw_wing : x_A_wing), (useOffset_wing ? y_A_top_draw_wing : y_A_top_wing))
        line.set_color(ln_BA_top_wing, activeRightColor_wing)

    if na(ln_BA_bot_wing)
        ln_BA_bot_wing := line.new(
         x1 = (useOffset_wing ? x_B_draw_wing : x_B_wing),
         y1 = y_B_bot_wing,
         x2 = (useOffset_wing ? x_A_draw_wing : x_A_wing),
         y2 = (useOffset_wing ? y_A_bot_draw_wing : y_A_bot_wing),
         xloc = xloc.bar_index,
         extend = extend.none,
         width = 1,
         color = activeRightColor_wing )
    else
        line.set_xy1(ln_BA_bot_wing, (useOffset_wing ? x_B_draw_wing : x_B_wing), y_B_bot_wing)
        line.set_xy2(ln_BA_bot_wing, (useOffset_wing ? x_A_draw_wing : x_A_wing), (useOffset_wing ? y_A_bot_draw_wing : y_A_bot_wing))
        line.set_color(ln_BA_bot_wing, activeRightColor_wing)

    if not na(lf_BA_wing)
        linefill.delete(lf_BA_wing)
    lf_BA_wing := linefill.new(ln_BA_top_wing, ln_BA_bot_wing, color = color.new(activeRightColor_wing, fillTrans_wing))

_angle_text_color_wing(angDeg) =>
    na(angDeg) ? color.new(textCol, 60) :
     math.abs(angDeg) < nearZeroDeg_wing ? #98999eb7 :
     angDeg > 0 ? textCol : negColor

if barstate.islast and not na(hud)
    table.cell(hud, 2, 2, "????C→B top = " + "\n" + "\n" +  "????"+ _fmt_deg_wing(angDegN_CB_top_wing), text_color = _angle_text_color_wing(angDegN_CB_top_wing), bgcolor = panelBG, text_size = size.small, text_halign = text.align_left)
    table.cell(hud, 2, 3, "????C→B bot = " + "\n" + "\n" +  "????"+_fmt_deg_wing(angDegN_CB_bot_wing), text_color = _angle_text_color_wing(angDegN_CB_bot_wing), bgcolor = panelBG, text_size = size.small, text_halign = text.align_left)
    table.cell(hud, 3, 2, "????B→A top = " + "\n" + "\n" +  "????"+_fmt_deg_wing(angDegN_BA_top_wing), text_color = _angle_text_color_wing(angDegN_BA_top_wing), bgcolor = panelBG, text_size = size.small, text_halign = text.align_left)
    table.cell(hud, 3, 3, "????B→A bot = " + "\n" + "\n" + "????"+_fmt_deg_wing(angDegN_BA_bot_wing), text_color = _angle_text_color_wing(angDegN_BA_bot_wing), bgcolor = panelBG, text_size = size.small, text_halign = text.align_left)

const int dec_ang          = 1   // rounding decimals
const int outColAlpha_ang  = 2   // fixed HUD column for α
const int outColBeta_ang   = 3   // fixed HUD column for β
const int outRow_ang       = 4   // fixed HUD row for α & β

int   iB_ang = int(math.floor((P - 1) / 2.0))
int   iC_ang = P - 1

int   x_A_ang = bar_index
int   x_B_ang = bar_index - iB_ang
int   x_C_ang = bar_index - iC_ang

float y_A_top_ang = high
float y_B_top_ang = high[iB_ang]
float y_C_top_ang = high[iC_ang]
float y_A_bot_ang = low
float y_B_bot_ang = low[iB_ang]
float y_C_bot_ang = low[iC_ang]

bool  ready_ang   = bar_index >= iC_ang and iC_ang > iB_ang and iB_ang > 0

float  atr_ang      = ta.atr(P)
float  atr_safe_ang = math.max(atr_ang, syminfo.mintick)  // avoid div-by-near-zero

_hypot_ang(x, y) => math.sqrt(x * x + y * y)

_clamp_ang(v, lo, hi) => v < lo ? lo : v > hi ? hi : v

_angle360_from_vectors_ang(ax, ay, b_x, b_y) =>
    dot    = ax * b_x + ay * b_y
    magA   = _hypot_ang(ax, ay)
    magB   = _hypot_ang(b_x, b_y)
    cosTh  = magA == 0 or magB == 0 ? na : _clamp_ang(dot / (magA * magB), -1.0, 1.0)
    base   = na(cosTh) ? na : math.todegrees(math.acos(cosTh))  // unsigned [0,180]
    crossZ = ax * b_y - ay * b_x
    na(base) ? na : (crossZ >= 0 ? base : 360.0 - base)

_avg2_na_ok_ang(a, b) => na(a) and na(b) ? na : na(a) ? b : na(b) ? a : (a + b) / 2.0

_roundN_ang(v, n) =>
    pow10 = math.pow(10.0, n)
    math.round(v * pow10) / pow10

float dx_L_ang = float(x_C_ang - x_B_ang)  // left wing (C←B), negative
float dx_R_ang = float(x_A_ang - x_B_ang)  // right wing (B→A), positive

float dy_L_top_n_ang = (y_C_top_ang - y_B_top_ang) / atr_safe_ang
float dy_R_top_n_ang = (y_A_top_ang - y_B_top_ang) / atr_safe_ang
float dy_L_bot_n_ang = (y_C_bot_ang - y_B_bot_ang) / atr_safe_ang
float dy_R_bot_n_ang = (y_A_bot_ang - y_B_bot_ang) / atr_safe_ang

float theta_top_ang = ready_ang ? _angle360_from_vectors_ang(dx_L_ang, dy_L_top_n_ang, dx_R_ang, dy_R_top_n_ang) : na
float theta_bot_ang = ready_ang ? _angle360_from_vectors_ang(dx_L_ang, dy_L_bot_n_ang, dx_R_ang, dy_R_bot_n_ang) : na
float theta_deg_ang = _avg2_na_ok_ang(theta_top_ang, theta_bot_ang)

alpha_deg_ang = na(theta_deg_ang) ? na : 360.0 - theta_deg_ang
beta_deg_ang  = theta_deg_ang

if barstate.islast and not na(hud)
    string aTxt = na(alpha_deg_ang) ? "∠α (Top) = —" : ("∠α (Top) = " + "\n" + "\n" + "????" + str.tostring(_roundN_ang(alpha_deg_ang, dec_ang)) + "°")
    string bTxt = na(beta_deg_ang)  ? "∠β (Bottom) = —" : ("∠β (Bottom) = " + "\n"+ "\n"  + "????" + str.tostring(_roundN_ang(beta_deg_ang,  dec_ang)) + "°")

    colAlpha = not na(alpha_deg_ang) and alpha_deg_ang > 180 ? negColor : textCol
    colBeta  = not na(beta_deg_ang)  and beta_deg_ang  < 180 ? negColor : textCol

    table.cell(hud, outColAlpha_ang, outRow_ang, aTxt, text_color = colAlpha, bgcolor = panelBG, text_size = size.small, text_halign = text.align_left, tooltip = "Top arc angle at vertex B (ATR-normalized). Red if > 180°.")
    table.cell(hud, outColBeta_ang,  outRow_ang, bTxt, text_color = colBeta,  bgcolor = panelBG, text_size = size.small, text_halign = text.align_left,  tooltip = "Bottom arc angle at vertex B (ATR-normalized). Red if < 180°.")

var line ln_alpha_dash_ang = na  // TOP (blue)
var line ln_beta_dash_ang  = na  // BOTTOM (red)

bool drawBlueTop_ang = ready_ang and not na(alpha_deg_ang) and alpha_deg_ang < 180
bool drawRedBot_ang  = ready_ang and not na(beta_deg_ang)  and beta_deg_ang  < 180

if drawBlueTop_ang
    if na(ln_alpha_dash_ang)
        ln_alpha_dash_ang := line.new(x1 = x_C_ang, y1 = y_C_top_ang, x2 = x_A_ang, y2 = y_A_top_ang,
             xloc = xloc.bar_index, extend = extend.none, width = 2, color = textCol, style = line.style_dashed)
    else
        line.set_xy1(ln_alpha_dash_ang, x_C_ang, y_C_top_ang)
        line.set_xy2(ln_alpha_dash_ang, x_A_ang, y_A_top_ang)
        line.set_color(ln_alpha_dash_ang, textCol)
else if not na(ln_alpha_dash_ang)
    line.delete(ln_alpha_dash_ang)
    ln_alpha_dash_ang := na

if drawRedBot_ang
    if na(ln_beta_dash_ang)
        ln_beta_dash_ang := line.new(x1 = x_C_ang, y1 = y_C_bot_ang, x2 = x_A_ang, y2 = y_A_bot_ang,
             xloc = xloc.bar_index, extend = extend.none, width = 2, color = negColor, style = line.style_dashed)
    else
        line.set_xy1(ln_beta_dash_ang, x_C_ang, y_C_bot_ang)
        line.set_xy2(ln_beta_dash_ang, x_A_ang, y_A_bot_ang)
        line.set_color(ln_beta_dash_ang, negColor)
else if not na(ln_beta_dash_ang)
    line.delete(ln_beta_dash_ang)
    ln_beta_dash_ang := na

const string GRP_OBOS_obos = "⑰ OB/OS Spike — Module"

bool    enableOBOS_obos   = input.bool(true,  title = "Activate OB/OS module", group = GRP_OBOS_obos,
     tooltip = "Turn the OverBought/OverSold spike detection on or off.")

int     minHits_obos      = input.int(3,     title = "Minimum hits (out of 7)", minval = 1, maxval = 7, group = GRP_OBOS_obos,
     tooltip = "Minimum number of oscillator overbought/oversold hits required for confirmation.")
int     syncWin_obos      = input.int(1,     title = "Bars for hit sync window", minval = 0, maxval = 2, group = GRP_OBOS_obos,
     tooltip = "Max with up to N previous bars' hit counts (0..2) to smooth spiky votes.")

int     volLen_obos       = input.int(55,    title = "Volume period", minval = 5, group = GRP_OBOS_obos,
     tooltip = "Lookback for TF-level volume SMA/STD used in spike detection.")
float   kVolRatio_obos    = input.float(1.6, title = "Volume spike threshold (Vol/SMA)", step = 0.1, group = GRP_OBOS_obos,
     tooltip = "Call a volume spike when Vol / SMA(Vol) ≥ threshold.")
float   zVolThr_obos      = input.float(1.8, title = "Z-Score volume threshold", step = 0.1, group = GRP_OBOS_obos,
     tooltip = "Alternative trigger: (Vol − SMA)/STD ≥ threshold.")

int     rsiLen_obos  = input.int(14, title = "RSI period",       minval = 2, group = GRP_OBOS_obos)
int     stLen_obos   = input.int(14, title = "Stochastic period", minval = 3, group = GRP_OBOS_obos)
int     stSm_obos    = input.int(3,  title = "Stochastic smoothing", minval = 1, group = GRP_OBOS_obos)
int     wprLen_obos  = input.int(14, title = "Williams %R period", minval = 3, group = GRP_OBOS_obos)
int     cciLen_obos  = input.int(27, title = "CCI period",       minval = 3, group = GRP_OBOS_obos)
int     mfiLen_obos  = input.int(14, title = "MFI period",       minval = 3, group = GRP_OBOS_obos)
int     demLen_obos  = input.int(14, title = "DeMarker period",  minval = 3, group = GRP_OBOS_obos)
int     srsiLen_obos = input.int(14, title = "Stochastic RSI period", minval = 3, group = GRP_OBOS_obos)

bool    useRSI_obos  = input.bool(true, title = "Enable RSI",          group = GRP_OBOS_obos)
bool    useSTO_obos  = input.bool(true, title = "Enable Stochastic",   group = GRP_OBOS_obos)
bool    useWPR_obos  = input.bool(true, title = "Enable Willia

Показано первые 50% кода (символов: 34869)

Что вы получите после оплаты

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
3 487₽