Stochastic Momentum Index (SMI) Signals + Stats [ForexCracked]

ForexCracked · study · 392 行 · 点赞 289 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This work is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International
// https://creativecommons.org/licenses/by-nc-sa/4.0/
// © ForexCracked
 
//@version=6
indicator("Stochastic Momentum Index (SMI) Signals + Stats [ForexCracked]", shorttitle = "SMI [FXC]", overlay = false, precision = 1, max_lines_count = 50, max_labels_count = 500)
 
// =====================================================================
// Stochastic Momentum Index (SMI) Signals + Stats v1.0
// SMI formula: William Blau (1993). Signal rules, plan, outcome record
// and any-bar comparison: original work.
// ---------------------------------------------------------------------
// THE SMI. Where the close sits against the MIDPOINT of the recent
// high-low range, with the distance and the range each smoothed twice by
// EMAs, scaled to -100..+100. It is drawn in this pane with its signal
// line and the two zones. Everything else is drawn on the price chart
// (force_overlay).
//
// TURNS. A close at or beyond a zone sets that side up: oversold for
// BUY, overbought for SELL. A return to zero clears the setup BEFORE the
// cross is read, so every BUY prints below zero and every SELL above it.
// While set up, the next cross of the signal line in the turning
// direction, on a closed bar, prints the signal. Every cross uses up its
// side's setup, even when the trend filter blocks the signal; a later
// close inside the zone sets it up again.
//
// THE PLAN. Entry at the signal close, stop a fixed ATR multiple away,
// target at the chosen reward:risk. The latest plan is drawn on price
// and projects into the empty space right of the last bar while open.
//
// THE RECORD. Every plan is followed from the next bar: target first,
// stop first, or neither inside the outcome window. A bar that opens
// beyond the target is target first; any other bar touching both lines
// is stop first. The outcome goes on the label when it happens, but the
// plan joins the counts only when its window ends, so quick and slow
// outcomes are counted on the same terms.
//
// THE COMPARISON. The same plan, under the same trend filter, is also
// started from EVERY closed bar and counted the same way. Both figures
// print side by side, the signal figure with a rough 95% noise band
// (1.96 standard errors), so the chart shows whether SMI timing did
// better than any-bar timing on this symbol and timeframe.
//
// Chart timeframe only (zero request.security). Signals and counts
// change on closed bars only. Plans are drawn and followed on standard
// bar and candle charts only.
// =====================================================================
 
// ---------------- INPUTS ----------------
gS = "SMI"
kLen   = input.int(10, "%K length (range)", minval = 2, maxval = 100, group = gS, tooltip = "Bars in the high-low range. The SMI measures the close against the midpoint of this range.")
sm1    = input.int(3, "First smoothing (EMA)", minval = 1, maxval = 50, group = gS)
sm2    = input.int(3, "Second smoothing (EMA)", minval = 1, maxval = 50, group = gS)
sigLen = input.int(10, "Signal line (EMA)", minval = 2, maxval = 50, group = gS)
zone   = input.float(40.0, "Zone level (+/-)", minval = 5.0, maxval = 95.0, step = 5.0, group = gS, tooltip = "Overbought at +level, oversold at -level. A close inside a zone sets that side up for its next cross of the signal line.")
 
gT = "Signals"
trendMode = input.string("Off", "Trend filter", options = ["Off", "With the trend", "Against the trend"], group = gT, tooltip = "Optional EMA filter on the chart timeframe. With the trend: BUY only above the EMA, SELL only below it. The any-bar comparison uses the same filter, so both figures describe the same kind of bar.")
trendLen  = input.int(200, "Trend EMA length", minval = 10, maxval = 500, group = gT)
showSig   = input.bool(true, "BUY / SELL labels on price", group = gT)
 
gP = "Plan and record"
atrLen   = input.int(14, "ATR length", minval = 5, maxval = 50, group = gP)
stopK    = input.float(1.5, "Stop distance (x ATR)", minval = 0.25, maxval = 5.0, step = 0.25, group = gP)
rr       = input.float(2.0, "Reward : risk", minval = 0.5, maxval = 5.0, step = 0.5, group = gP, tooltip = "Target distance = stop distance x this.")
winN     = input.int(50, "Outcome window (bars)", minval = 10, maxval = 100, group = gP, tooltip = "Neither line touched within this many bars counts as neither. Every plan joins the counts when this many bars have passed, however quickly it resolved.")
nMin     = input.int(20, "Minimum n before a percentage prints", minval = 10, maxval = 100, group = gP, tooltip = "Below this only the sample size prints.")
useBase  = input.bool(true, "Compare with the same plan from any bar", group = gP, tooltip = "Starts the same plan, under the same trend filter, from every closed bar and counts it the same way.")
showPlan = input.bool(true, "Latest plan on price", group = gP)
 
gV = "Style"
colorBars = input.bool(true, "Colour candles by SMI", group = gV, tooltip = "Teal while the SMI is above zero, pink below it. Faded while the SMI is on the other side of its signal line.")
extN      = input.int(10, "Project the plan right (bars)", minval = 3, maxval = 50, group = gV)
showTbl   = input.bool(true, "Panel on price", group = gV)
tblPosIn  = input.string("Top Right", "Panel position", options = ["Top Right", "Top Left", "Bottom Right", "Bottom Left"], group = gV)
colUp     = input.color(#2dd4bf, "Bullish", group = gV)
colDn     = input.color(#e84e89, "Bearish", group = gV)
colNav    = input.color(#1a2c4c, "Label ground", group = gV)
tblPos    = tblPosIn == "Top Left" ? position.top_left : tblPosIn == "Bottom Right" ? position.bottom_right : tblPosIn == "Bottom Left" ? position.bottom_left : position.top_right
 
// ---------------- SMI ----------------
hiK  = ta.highest(high, kLen)
loK  = ta.lowest(low, kLen)
relS = ta.ema(ta.ema(close - (hiK + loK) / 2, sm1), sm2)
rngS = ta.ema(ta.ema(hiK - loK, sm1), sm2)
smi  = na(rngS) ? na : rngS > 0 ? 200.0 * relS / rngS : 0.0
sig  = ta.ema(smi, sigLen)
 
atr  = ta.atr(atrLen)
tEma = ta.ema(close, trendLen)
upX  = ta.crossover(smi, sig)
dnX  = ta.crossunder(smi, sig)
 
trendOn = trendMode != "Off"
withT   = trendMode == "With the trend"
longOk  = not trendOn or (not na(tEma) and (withT ? close > tEma : close < tEma))
shortOk = not trendOn or (not na(tEma) and (withT ? close < tEma : close > tEma))
 
warmBars = kLen + 3 * (sm1 + sm2 + sigLen)
// the stop must sit at least one tick from the entry, or both lines round onto it
ready    = bar_index >= warmBars and not na(sig) and not na(atr) and stopK * atr >= syminfo.mintick
mut      = barstate.isconfirmed and ready
stdChart = chart.is_standard
 
// pips on 5-digit and 3-digit forex feeds; price units everywhere else
isFx    = syminfo.type == "forex" and (syminfo.mintick == 0.00001 or syminfo.mintick == 0.001)
pipSize = syminfo.mintick * (isFx ? 10 : 1)
distTxt(float d) => isFx ? str.tostring(math.round(math.abs(d) / pipSize, 1)) + "p" : str.tostring(math.abs(d), format.mintick)
pxTxt(float p)   => str.tostring(p, format.mintick)
nTxt(int n)      => str.tostring(n, "#,##0")
pctTxt(int k, int n) => str.tostring(math.round(100.0 * k / n)) + "%"
// rough 95% band of a share from n events, in percentage points (1.96 standard errors)
bandTxt(int k, int n) =>
    p = 1.0 * k / n
    "±" + str.tostring(math.max(1, math.round(196.0 * math.sqrt(p * (1.0 - p) / n))))
 
// short forms for labels and the panel: count + percent + n, nothing below nMin
recTxt(int tp, int sl, int ne) =>
    n = tp + sl + ne
    n >= nMin ? "TP first " + nTxt(tp) + "/" + nTxt(n) + " (" + pctTxt(tp, n) + " " + bandTxt(tp, n) + ")" : "n=" + nTxt(n) + " (<" + str.tostring(nMin) + ")"
baseTxt(int tp, int sl, int ne) =>
    n = tp + sl + ne
    n >= nMin ? "any bar " + pctTxt(tp, n) + " of " + nTxt(n) : "any bar n=" + nTxt(n)
fullTxt(int tp, int sl, int ne) =>
    "TP first " + nTxt(tp) + " · SL first " + nTxt(sl) + " · neither " + nTxt(ne) + " (n=" + nTxt(tp + sl + ne) + ")"
 
// ---------------- TURNS (closed bars only) ----------------
var bool armUp = false
var bool armDn = false
buy  = false
sell = false
if mut
    if smi <= -zone
        armUp := true
    if smi >= zone
        armDn := true
    // a return to zero clears a setup before the cross is read
    if smi >= 0
        armUp := false
    if smi <= 0
        armDn := false
    buy  := armUp and upX and longOk
    sell := armDn and dnX and shortOk
    // every cross uses up its side's setup, even when the trend filter blocks the signal
    if upX
        armUp := false
    if dnX
        armDn := false
 
planDir  = buy ? 1 : sell ? -1 : 0
planStop = planDir != 0 ? math.round_to_mintick(close - planDir * stopK * atr) : na
planTgt  = planDir != 0 ? math.round_to_mintick(close + planDir * stopK * rr * atr) : na
 
// ---------------- RECORD STATE ----------------
var array<int>   pKind = array.new<int>()     // 0 signal plan, 1 any-bar plan
var array<int>   pDir  = array.new<int>()     // 1 long, -1 short
var array<float> pStop = array.new<float>()
var array<float> pTgt  = array.new<float>()
var array<int>   pBar  = array.new<int>()
var array<int>   pRes  = array.new<int>()     // -1 open, 0 neither, 1 stop first, 2 target first
var array<label> pLbl  = array.new<label>()
 
var int tpL  = 0
var int slL  = 0
var int neL  = 0
var int tpS  = 0
var int slS  = 0
var int neS  = 0
var int aTpL = 0
var int aSlL = 0
var int aNeL = 0
var int aTpS = 0
var int aSlS = 0
var int aNeS = 0
var int capSkip = 0
 
// the latest signal and its drawn plan
var int   lastDir = 0
var int   lastBar = na
var int   lastRes = -1
var line  eLn = na
var line  sLn = na
var line  tLn = na
var label eLb = na
var label sLb = na
var label tLb = na
var label lastLb = na
 
// ---------------- RECORD: follow every plan on closed bars ----------------
// Plans born on earlier bars only. The outcome is decided at the first touch,
// the plan is counted when its window ends.
if barstate.isconfirmed and stdChart and array.size(pDir) > 0
    for i = array.size(pDir) - 1 to 0
        d   = array.get(pDir, i)
        k   = array.get(pKind, i)
        age = bar_index - array.get(pBar, i)
        res = array.get(pRes, i)
        if res < 0
            st   = array.get(pStop, i)
            tg   = array.get(pTgt, i)
            gapT = d == 1 ? open >= tg : open <= tg
            hitS = d == 1 ? low <= st : high >= st
            hitT = d == 1 ? high >= tg : low <= tg
            res := gapT ? 2 : hitS ? 1 : hitT ? 2 : age >= winN ? 0 : -1
            if res >= 0
                array.set(pRes, i, res)
                if k == 0
                    lb = array.get(pLbl, i)
                    if not na(lb)
                        // the outcome goes on the first line; any figure lines below it stay
                        txt    = label.get_text(lb)
                        cut    = str.pos(txt, "\n")
                        outTxt = res == 2 ? " · TP " + str.tostring(age) + "b" : res == 1 ? " · SL " + str.tostring(age) + "b" : " · none in " + str.tostring(winN) + "b"
                        label.set_text(lb, na(cut) ? txt + outTxt : str.substring(txt, 0, cut) + outTxt + str.substring(txt, cut))
                    if not na(lastBar) and array.get(pBar, i) == lastBar
                        lastRes := res
                        if not na(eLn)
                            line.set_x2(eLn, bar_index)
                            line.set_x2(sLn, bar_index)
                            line.set_x2(tLn, bar_index)
                            label.set_x(eLb, bar_index)
                            label.set_x(sLb, bar_index)
                            label.set_x(tLb, bar_index)
        if res >= 0 and age >= winN
            if k == 0
                if d == 1
                    tpL += res == 2 ? 1 : 0
                    slL += res == 1 ? 1 : 0
                    neL += res == 0 ? 1 : 0
                else
                    tpS += res == 2 ? 1 : 0
                    slS += res == 1 ? 1 : 0
                    neS += res == 0 ? 1 : 0
            else
                if d == 1
                    aTpL += res == 2 ? 1 : 0
                    aSlL += res == 1 ? 1 : 0
                    aNeL += res == 0 ? 1 : 0
                else
                    aTpS += res == 2 ? 1 : 0
                    aSlS += res == 1 ? 1 : 0
                    aNeS += res == 0 ? 1 : 0
            array.remove(pKind, i)
            array.remove(pDir, i)
            array.remove(pStop, i)
            array.remove(pTgt, i)
            array.remove(pBar, i)
            array.remove(pRes, i)
            array.remove(pLbl, i)
 
// ---------------- SIGNAL: label, drawn plan, record entry ----------------
if buy or sell
    head     = buy ? "BUY" : "SELL"
    recNow   = buy ? recTxt(tpL, slL, neL) : recTxt(tpS, slS, neS)
    baseNow  = buy ? baseTxt(aTpL, aSlL, aNeL) : baseTxt(aTpS, aSlS, aNeS)
    statLine = stdChart ? recNow + (useBase ? "\n" + baseNow : "") : "record kept on standard charts only"
    tip = head + " turn from " + (buy ? "oversold" : "overbought") + ": SMI " + str.tostring(smi, "0.0") + " crossed " + (buy ? "above" : "below") + " its signal line (" + str.tostring(sig, "0.0") + ")"
    if stdChart
        tip := tip + "\nEntry " + pxTxt(close) + " · stop " + pxTxt(planStop) + " (" + distTxt(close - planStop) + ") · target " + pxTxt(planTgt) + " (" + distTxt(planTgt - close) + ")"
        tip := tip + "\nEarlier " + head + " turns on this chart: " + (buy ? fullTxt(tpL, slL, neL) : fullTxt(tpS, slS, neS))
        if useBase
            tip := tip + "\nSame plan from any bar: " + (buy ? fullTxt(aTpL, aSlL, aNeL) : fullTxt(aTpS, aSlS, aNeS))
        tip := tip + "\nFigures as they stood at this signal, on the history loaded. Only the outcome is added later."
    else
        tip := tip + "\nNo plan on this chart type: it does not trade at the prices it draws."
 
    // the previous newest label keeps only its first line (signal + outcome); its figures stay in its tooltip
    if not na(lastLb)
        prevTxt = label.get_text(lastLb)
        prevCut = str.pos(prevTxt, "\n")
        if not na(prevCut)
            label.set_text(lastLb, str.substring(prevTxt, 0, prevCut))
    label lb = na
    if showSig
        lb := label.new(bar_index, buy ? low : high, head + "\n" + statLine, yloc = buy ? yloc.belowbar : yloc.abovebar, style = buy ? label.style_label_up : label.style_label_down, color = buy ? colUp : colDn, textcolor = buy ? colNav : color.white, size = size.small, tooltip = tip, force_overlay = true)
    lastLb  := lb
    lastDir := planDir
    lastBar := bar_index
    lastRes := -1
 
    if showPlan and stdChart
        if not na(eLn)
            line.delete(eLn)
            line.delete(sLn)
            line.delete(tLn)
            label.delete(eLb)
            label.delete(sLb)
            label.delete(tLb)
        x2 = bar_index + extN
        eLn := line.new(bar_index, close, x2, close, color = color.new(#94a3b8, 0), style = line.style_dashed, width = 1, force_overlay = true)
        sLn := line.new(bar_index, planStop, x2, planStop, color = colDn, width = 2, force_overlay = true)
        tLn := line.new(bar_index, planTgt, x2, planTgt, color = colUp, width = 2, force_overlay = true)
        // right-anchored styles so the text sits left of the line end, over empty space
        eLb := label.new(x2, close, head + " " + pxTxt(close), style = buy ? label.style_label_upper_right : label.style_label_lower_right, color = color.new(colNav, 15), textcolor = color.white, size = size.small, force_overlay = true)
        tLb := label.new(x2, planTgt, "TP " + pxTxt(planTgt) + " (" + (buy ? "+" : "-") + distTxt(planTgt - close) + ")", style = buy ? label.style_label_lower_right : label.style_label_upper_right, color = color.new(colNav, 15), textcolor = colUp, size = size.small, force_overlay = true)
        sLb := label.new(x2, planStop, "SL " + pxTxt(planStop) + " (" + (buy ? "-" : "+") + distTxt(close - planStop) + ")", style = buy ? label.style_label_upper_right : label.style_label_lower_right, color = color.new(colNav, 15), textcolor = colDn, size = size.small, force_overlay = true)
 
    // followed from the next bar; a full store skips the newcomer and never evicts an open plan
    if stdChart
        if array.size(pDir) < 2000
            array.push(pKind, 0)
            array.push(pDir, planDir)
            array.push(pStop, planStop)
            array.push(pTgt, planTgt)
            array.push(pBar, bar_index)
            array.push(pRes, -1)
            array.push(pLbl, lb)
        else
            capSkip += 1
 
// ---------------- ANY-BAR COMPARISON: the same plan from every closed bar ----------------
if mut and stdChart and useBase
    if longOk and array.size(pDir) < 2000
        array.push(pKind, 1)
        array.push(pDir, 1)
        array.push(pStop, math.round_to_mintick(close - stopK * atr))
        array.push(pTgt, math.round_to_mintick(close + stopK * rr * atr))
        array.push(pBar, bar_index)
        array.push(pRes, -1)
        array.push(pLbl, na)
    if shortOk and array.size(pDir) < 2000
        array.push(pKind, 1)
        array.push(pDir, -1)
        array.push(pStop, math.round_to_mintick(close + stopK * atr))
        array.push(pTgt, math.round_to_mintick(close - stopK * rr * atr))
        array.push(pBar, bar_index)
        array.push(pRes, -1)
        array.push(pLbl, na)
 
// keep the open plan reaching into the space right of the last bar
if showPlan and stdChart and not na(eLn) and lastRes < 0
    xr = bar_index + extN
    line.set_x2(eLn, xr)
    line.set_x2(sLn, xr)
    line.set_x2(tLn, xr)
    label.set_x(eLb, xr)
    label.set_x(sLb, xr)
    label.set_x(tLb, xr)
 
// ---------------- PANE: the SMI ----------------
pSmi = plot(smi, "SMI", color = smi >= sig ? colUp : colDn, linewidth = 2)
pSig = plot(sig, "Signal line", color = color.new(#94a3b8, 0), linewidth = 1)
fill(pSmi, pSig, color = smi >= sig ? color.new(colUp, 80) : color.new(colDn, 80), title = "SMI vs signal")
hOb  = hline(zone, "Overbought", color = color.new(#e84e89, 30), linestyle = hline.style_dashed)
hOs  = hline(-zone, "Oversold", color = color.new(#2dd4bf, 30), linestyle = hline.style_dashed)
hTop = hline(100, "Top", color = color.new(#94a3b8, 100))
hBot = hline(-100, "Bottom", color = color.new(#94a3b8, 100))
hline(0, "Zero line", color = color.new(#94a3b8, 50), linestyle = hline.style_dotted)
fill(hTop, hOb, color = color.new(#e84e89, 90), title = "Overbought zone")
fill(hOs, hBot, color = color.new(#2dd4bf, 90), title = "Oversold zone")
bgcolor(armUp ? color.new(colUp, 90) : armDn ? color.new(colDn, 90) : na, title = "Side set up, waiting for its cross")
plotshape(buy ? smi : na, title = "BUY turn", style = shape.circle, location = location.absolute, color = colUp, size = size.tiny, display = display.pane)
plotshape(sell ? smi : na, title = "SELL turn", style = shape.circle, location = location.absolute, color = colDn, size = size.tiny, display = display.pane)
 
// ---------------- PRICE CHART ----------------
candleCol = colorBars and not na(smi) and not na(sig) ? (smi > 0 ? (smi >= sig ? colUp : color.new(colUp, 55)) : (smi <= sig ? colDn : color.new(colDn, 55))) : na
barcolor(candleCol, title = "SMI candles")
plot(trendOn ? tEma : na, "Trend EMA", color = color.new(#94a3b8, 25), linewidth = 1, display = display.pane, force_overlay = true)
 
// ---------------- PANEL (on price) ----------------
var table tbl = table.new(tblPos, 2, 6, bgcolor = color.new(colNav, 8), frame_color = color.new(color.gray, 55), frame_width = 1, border_color = color.new(#2a3d63, 25), border_width = 1, force_overlay = true)
if barstate.islast and showTbl
    openN = 0
    if array.size(pKind) > 0
        for j = 0 to array.size(pKind) - 1
            if array.get(pKind, j) == 0
                openN += 1
    // one clock for the whole row: the last closed bar, the same bar the setup was read on
    smiC    = barstate.isconfirmed ? smi : smi[1]
    sigC    = barstate.isconfirmed ? sig : sig[1]
    stTxt   = na(smiC) or na(sigC) ? "warming up" : str.tostring(smiC, "0.0") + " vs signal " + str.tostring(sigC, "0.0") + (smiC <= -zone ? " · oversold" : smiC >= zone ? " · overbought" : "") + (armUp ? " · waiting for a BUY cross" : armDn ? " · waiting for a SELL cross" : "")
    lastTxt = lastDir == 0 ? "none yet" : (lastDir == 1 ? "BUY" : "SELL") + " · " + str.tostring(bar_index - lastBar) + " bars ago · " + (not stdChart ? "not followed on this chart type" : lastRes < 0 ? "open" : lastRes == 2 ? "TP first" : lastRes == 1 ? "SL first" : "neither")
    howTip  = "A plan joins the counts when its window ends. A bar that opens beyond the target is target first; any other bar touching both lines is stop first. The ± is a rough 95% noise band for that many signals."
    table.cell(tbl, 0, 0, "Stochastic Momentum Index", text_color = color.white, text_size = size.small, bgcolor = color.new(#0f1d36, 0))
    table.cell(tbl, 1, 0, syminfo.ticker + " " + timeframe.period, text_color = colUp, text_size = size.small, bgcolor = color.new(#0f1d36, 0))
    table.cell(tbl, 0, 1, "SMI at last close", text_color = color.gray, text_size = size.tiny)
    table.cell(tbl, 1, 1, stTxt, text_color = smiC >= sigC ? colUp : colDn, text_size = size.tiny)
    table.cell(tbl, 0, 2, "BUY turns", text_color = color.gray, text_size = size.tiny)
    table.cell(tbl, 1, 2, stdChart ? recTxt(tpL, slL, neL) + (useBase ? " · " + baseTxt(aTpL, aSlL, aNeL) : "") : "record kept on standard charts only", text_color = colUp, text_size = size.tiny, tooltip = stdChart ? fullTxt(tpL, slL, neL) + (useBase ? "\nSame plan from any bar: " + fullTxt(aTpL, aSlL, aNeL) : "") + "\n" + howTip : "")
    table.cell(tbl, 0, 3, "SELL turns", text_color = color.gray, text_size = size.tiny)
    table.cell(tbl, 1, 3, stdChart ? recTxt(tpS, slS, neS) + (useBase ? " · " + baseTxt(aTpS, aSlS, aNeS) : "") : "record kept on standard charts only", text_color = colDn, text_size = size.tiny, tooltip = stdChart ? fullTxt(tpS, slS, neS) + (useBase ? "\nSame plan from any bar: " + fullTxt(aTpS, aSlS, aNeS) : "") + "\n" + howTip : "")
    table.cell(tbl, 0, 4, "Plan", text_color = color.gray, text_size = size.tiny)
    table.cell(tbl, 1, 4, "SL " + str.tostring(stopK, "0.##") + " ATR · TP " + str.tostring(rr, "0.##") + "R · " + str.tostring(winN) + "-bar window · " + str.tostring(openN) + " not yet counted" + (capSkip > 0 ? " · " + str.tostring(capSkip) + " not followed" : ""), text_color = color.white, text_size = size.tiny, tooltip = howTip)
    table.cell(tbl, 0, 5, "Last signal", text_color = color.gray, text_size = size.tiny)
    table.cell(tbl, 1, 5, lastTxt, text_color = lastDir == 1 ? colUp : lastDir == -1 ? colDn : color.white, text_size = size.tiny)
 
// ---------------- ALERTS ----------------
alertcondition(buy, "SMI BUY turn", "SMI BUY turn on {{ticker}} {{interval}}")
alertcondition(sell, "SMI SELL turn", "SMI SELL turn on {{ticker}} {{interval}}")
alertcondition(buy or sell, "SMI any turn", "SMI turn on {{ticker}} {{interval}}")
if buy or sell
    alert((buy ? "BUY" : "SELL") + " SMI turn on " + syminfo.ticker + " " + timeframe.period + (stdChart ? " · entry " + pxTxt(close) + " · stop " + pxTxt(planStop) + " · target " + pxTxt(planTgt) : ""), alert.freq_once_per_bar_close)

← 返回列表