Skip to content
Nexus Prop LLC

NexuScript 1.5

Example scripts.

The example indicators the script editor offers, complete. Copy one, paste it into a new script and press Run. Every name a script uses links to its entry in the reference.

EMA cross

Two moving averages with a mark where they cross.

# Two moving averages with a mark where they cross.
nexscript 1

indicator "EMA cross", overlay = true

input fast_length = 9, title = "Fast length", min = 1, max = 500
input slow_length = 21, title = "Slow length", min = 1, max = 500

on bar
    let fast = ta.ema(close, fast_length)
    let slow = ta.ema(close, slow_length)
    plot("Fast", fast, color = color.blue, width = 2)
    plot("Slow", slow, color = color.orange, width = 2)
    if ta.crossover(fast, slow)
        marker("UP", position = "below", shape = "arrow_up", color = color.green)
    end
    if ta.crossunder(fast, slow)
        marker("DOWN", position = "above", shape = "arrow_down", color = color.red)
    end
end

Usesnexscriptindicatorinputletta.emacloseplotcolor.bluecolor.orangeifta.crossovermarkercolor.greenta.crossundercolor.redon bar

RSI with levels

RSI with overbought and oversold levels, shaded when it is past one.

# RSI with overbought and oversold levels, shaded when it is past one.
nexscript 1

indicator "RSI with levels", short = "RSI"

input length = 14, title = "Length", min = 1, max = 500
input src = close, title = "Source"
input upper = 70, title = "Overbought", min = 50, max = 100
input lower = 30, title = "Oversold", min = 0, max = 50

level "Overbought", upper, color = color.red
level "Oversold", lower, color = color.green

on bar
    let rsi = ta.rsi(src, length)
    plot("RSI", rsi, color = color.purple, width = 2)
    if rsi >= upper
        background(color.fade(color.red, 90))
    elseif rsi <= lower
        background(color.fade(color.green, 90))
    end
end

Usesnexscriptindicatorinputcloselevelcolor.redcolor.greenletta.rsiplotcolor.purpleifbackgroundcolor.fadeon bar

Session opening range

High and low of the first minutes of a session, held for the rest of it.

# High and low of the first minutes of a session, held for the rest of it.
nexscript 1

indicator "Session opening range", overlay = true, short = "Range"

input window = "0930-1600", title = "Session"
input zone = "America/New_York", title = "Time zone"
input range_minutes = 15, title = "Range minutes", min = 1, max = 240

state range_high = missing
state range_low = missing

on bar
    let minutes = session.elapsed(window, zone = zone)
    if session.starts(window, zone = zone)
        range_high = missing
        range_low = missing
    end
    if minutes < range_minutes
        range_high = max(coalesce(range_high, high), high)
        range_low = min(coalesce(range_low, low), low)
    end
    let broke_up = ta.crossover(close, range_high)
    let broke_down = ta.crossunder(close, range_low)
    if minutes >= range_minutes
        plot("Range high", range_high, color = color.green, width = 2, style = "step")
        plot("Range low", range_low, color = color.red, width = 2, style = "step")
        band("Range high", "Range low", color = color.fade(color.gray, 88))
        if broke_up
            marker("BREAK", position = "below", shape = "arrow_up", color = color.green)
        end
        if broke_down
            marker("BREAK", position = "above", shape = "arrow_down", color = color.red)
        end
    end
end

Usesnexscriptindicatorinputstateletsession.elapsedifsession.startsmaxcoalescehighminlowta.crossovercloseta.crossunderplotcolor.greencolor.redbandcolor.fadecolor.graymarkeron bar