Strategy · Pine Script v6 · On the chart

Crypto Long 10m Scalper BB RSI EMA Fib

by kanylbullen· code credited to Saletrader1

A long-only strategy for short-term crypto trading that combines Bollinger Bands, RSI, a 9-period EMA, a 21-period SMA and a Fibonacci window covering about ten minutes of bars.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code213
Settings9inputs
LicenceNone statedfile: MPL-2.0
Last update7 days ago22 Oct 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.

Source Code

213 lines of Pine Script v6 from tv-source/bb_rsi_scalper.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

bb_rsi_scalper.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Saletrader1

//@version=6
strategy(
     "Crypto LONG 10m Scalper BB+RSI+EMA+Fib (NY shading)",
     overlay           = true,
     initial_capital   = 100,
     default_qty_type  = strategy.percent_of_equity,
     default_qty_value = 30,
     pyramiding        = 1,
     commission_type   = strategy.commission.percent,
     commission_value  = 0.06)


// Solo LONG
strategy.risk.allow_entry_in(strategy.direction.long)

//---------------------------------------------------------
// 1) Sesión New York (visual, no filtro por defecto)
//---------------------------------------------------------
sessionNY   = input.session("0930-1600", "Horario sesión NY (ej. 09:30-16:00)")
inSessionNY = not na(time(timeframe.period, sessionNY))
useNyFilter = input.bool(false, "Operar solo en horario NY?")

dayNum    = dayofmonth(time)
isEvenDay = (dayNum % 2) == 0
sessColor = isEvenDay ? color.new(color.purple, 50) : color.new(color.blue, 30)
bgcolor(inSessionNY ? sessColor : na)

// Tabla con horarios NY
var table nyTable = table.new(position.bottom_right, 1, 4, border_width = 1)
if barstate.islast
    table.cell(nyTable, 0, 0, "NY Regular:",         text_color = color.white, bgcolor = color.new(color.black, 80))
    table.cell(nyTable, 0, 1, "09:30 - 16:00",       text_color = color.white, bgcolor = color.new(color.black, 80))
    table.cell(nyTable, 0, 2, "Pre: 04:00 - 09:30",  text_color = color.white, bgcolor = color.new(color.black, 80))
    table.cell(nyTable, 0, 3, "Post:16:00 - 20:00",  text_color = color.white, bgcolor = color.new(color.black, 80))

sessionOK = useNyFilter ? inSessionNY : true

//---------------------------------------------------------
// 2) Parámetros
//---------------------------------------------------------
bbLength   = input.int(20,    "Bollinger Length")
bbMult     = input.float(2.0, "Bollinger Mult", step = 0.1)
rsiLength  = input.int(14,    "RSI Length")
emaLength  = input.int(9,     "EMA 9 Length")
smaLength  = input.int(21,    "SMA 21 Length")

// Beneficio mínimo > 0 para permitir cerrar
minProfitPct  = input.float(0.1, "Beneficio mínimo para cerrar (%)", minval = 0.0, maxval = 20.0)
minProfitFrac = minProfitPct / 100.0

// Umbral cruce inminente EMA9 vs SMA21 (para salida técnica)
deltaPctIn  = input.float(1.0, "Delta cruce inminente EMA9~SMA21 (%)", minval = -1.0, maxval = 3.0)
deltaThresh = deltaPctIn / 100.0

// Tiempo máximo en operación: 10 minutos
holdMinutes   = 10
holdMs        = holdMinutes * 60 * 1000

//---------------------------------------------------------
// 3) Indicadores básicos
//---------------------------------------------------------
[basis, bbUpper, bbLower] = ta.bb(close, bbLength, bbMult)
rsi   = ta.rsi(close, rsiLength)
ema9  = ta.ema(close, emaLength)
sma21 = ta.sma(close, smaLength)

delta = sma21 != 0.0 ? (ema9 - sma21) / sma21 : 0.0

//---------------------------------------------------------
// 4) Fibonacci en ventana de 10 minutos
//---------------------------------------------------------
// Convertimos 10 minutos a número de velas según el timeframe actual
tfSec      = timeframe.in_seconds(timeframe.period)
barsFibRaw = 600.0 / tfSec
barsFib    = math.max(3, int(math.round(barsFibRaw)))  // mínimo 3 barras

swingHigh  = ta.highest(high, barsFib)
swingLow   = ta.lowest(low,  barsFib)
validSwing = swingHigh > swingLow

fib38 = validSwing ? (swingLow + (swingHigh - swingLow) * 0.382) : na
fib62 = validSwing ? (swingLow + (swingHigh - swingLow) * 0.618) : na

// Dibujamos como soportes/resistencias
plot(fib38, title = "Fib 38.2%", color = color.new(color.teal, 0), linewidth = 1, style = plot.style_linebr)
plot(fib62, title = "Fib 61.8%", color = color.new(color.orange, 0), linewidth = 1, style = plot.style_linebr)

// Zona dorada
fibLow  = na(fib38) or na(fib62) ? na : (fib38 < fib62 ? fib38 : fib62)
fibHigh = na(fib38) or na(fib62) ? na : (fib38 > fib62 ? fib38 : fib62)
inFibZone = validSwing and not na(fibLow) and not na(fibHigh) and close >= fibLow and close <= fibHigh

//---------------------------------------------------------
// 5) Lógica de compra
//---------------------------------------------------------
// Tendencia bajista: precio bajo la SMA21 y SMA21 descendiendo
trendDown = close < sma21 and sma21 < sma21[1]

// EMA 9 girando al alza
emaTurnUp = ema9 > ema9[1] and ema9[1] < ema9[2]

// Compra en tendencia no bajista (setup original BB+RSI+EMA+Fib)
buyUptrend =
     not trendDown and
     close < bbLower and
     rsi < 20 and
     emaTurnUp and
     inFibZone

// Valle en tendencia bajista: valle en low[1] + EMA9 sube ahora
valleyDown =
     trendDown and
     inFibZone and
     ema9 > ema9[1] and
     low[1] < low[2] and
     low[1] < low

buyDowntrend = valleyDown

// Condición final de entrada
canEnter = strategy.position_size == 0 and sessionOK
enterLong = canEnter and (buyUptrend or buyDowntrend)

//---------------------------------------------------------
// 6) Lógica de venta
//---------------------------------------------------------
// Señal técnica (BB sup + RSI alto + cruce inminente EMA/SMA)
sellSignal =
     strategy.position_size > 0 and
     close > bbUpper and
     rsi > 81 and
     ema9 > sma21 and
     delta <= deltaThresh

avgPrice = strategy.position_avg_price
haveProfit = avgPrice > 0 and close >= avgPrice * (1.0 + minProfitFrac)

// Control de tiempo en operación (10 minutos)
var int entryTime = na
if enterLong
    entryTime := time

inPosition = strategy.position_size > 0 and not na(entryTime)
timeLimitReached = inPosition and (time - entryTime >= holdMs)

// Salidas:
// 1) Señal técnica + ganancia
exitBySignal = sessionOK and sellSignal and haveProfit
// 2) Fin de los 10 minutos + ganancia (aunque no haya señal)
exitByTime   = sessionOK and timeLimitReached and haveProfit

exitLong = exitBySignal or exitByTime

if enterLong
    strategy.entry("LONG", strategy.long)

if exitLong
    strategy.close("LONG")
    entryTime := na

//---------------------------------------------------------
// 7) Etiquetas BUY/SELL con PnL
//---------------------------------------------------------
var label lastBuyLabel  = na
var label lastSellLabel = na

if enterLong
    if not na(lastBuyLabel)
        label.delete(lastBuyLabel)
    lastBuyLabel := label.new(
         bar_index,
         low,
         "BUY\n" + str.tostring(close, format.mintick),
         style     = label.style_label_up,
         color     = color.new(color.green, 0),
         textcolor = color.white,
         size      = size.tiny
     )

if exitLong
    pnlPerc = avgPrice != 0.0 ? (close - avgPrice) / avgPrice * 100.0 : na
    if not na(lastSellLabel)
        label.delete(lastSellLabel)
    lastSellLabel := label.new(
         bar_index,
         high,
         "SELL\n" +
         str.tostring(close, format.mintick) +
         "\nP&L: " + str.tostring(pnlPerc, "#.##") + "%",
         style     = label.style_label_down,
         color     = color.new(color.red, 0),
         textcolor = color.white,
         size      = size.tiny
     )

//---------------------------------------------------------
// 8) Plots de referencia
//---------------------------------------------------------
plot(bbUpper, "BB Upper", color = color.new(color.blue, 40))
plot(basis,   "BB Basis", color = color.new(color.orange, 60))
plot(bbLower, "BB Lower", color = color.new(color.blue, 40))

plot(ema9,  "EMA 9",  color = color.new(color.yellow, 0))
plot(sma21, "SMA 21", color = color.new(color.fuchsia, 0))

plotshape(enterLong, title = "Señal LONG", style = shape.triangleup,
          location = location.belowbar, color = color.lime, size = size.tiny, text = "L")

plotshape(exitLong, title = "Señal SELL", style = shape.triangledown,
          location = location.abovebar, color = color.red, size = size.tiny, text = "S")

Overview

Crypto Long 10m Scalper BB RSI EMA Fib sizes positions as a percentage of equity and can require a minimum gain before closing, with an inclusion threshold for an imminent EMA and SMA cross. An optional New York session filter and background shading are included. Positions are meant to be held for a short time.

Details

Published by

kanylbullen on GitHub

Code credit

Saletrader1, as written in the script's header

Draws

On the price chart

Markets

Crypto

Timeframes

M1-M5

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Horario sesión NY (ej. 09:30-16:00)session0930-1600sessionNY
Operar solo en horario NY?boolfalseuseNyFilter
Bollinger Lengthint20bbLength
Bollinger Multfloat2.0bbMult
RSI Lengthint14rsiLength
EMA 9 Lengthint9emaLength
SMA 21 Lengthint21smaLength
Beneficio mínimo para cerrar (%)float0.1minProfitPct
Delta cruce inminente EMA9~SMA21 (%)float1.0deltaPctIn
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

2 stars

This strategy identifies price consolidation ranges during Asia session hours and trades mean-reversion reclaims following liquidity sweeps. It marks an initial range box, measures sweep depths past box boundaries using ATR multiples, and enters trades when pr

Strategy v6 Sessions & timeDivergence
Updated 4 weeks ago · Custom licence GitHub repository of MP Asia Range Sweep & Reclaim

Quick Flip Scalper

by TradersPost
228 stars

This strategy executes an opening-range liquidity fade based on the first candle of a session. It qualifies the opening range against the daily ATR to confirm manipulation or liquidity spikes. If qualified, it searches for reversal candlestick patterns, such a

Strategy v6 Sessions & timeCandlestick patterns
Updated 3 months ago · None stated GitHub repository of Quick Flip Scalper

S Trailing

by GammaExpansion
1 stars

S Trailing is a Pine Script v6 strategy that applies trailing stops to periodic cycle-based entries. It divides the bar index into cycles of 40 bars and activates at specific phases: long entry with trailing price stop at phase 0, short entry at phase 14, plus

Strategy v6 Mean reversionScalping
Updated 6 days ago · MIT GitHub repository of S Trailing

3C QFL Mean Reversal

by hasnocool
106 stars

3C QFL Mean Reversal is a strategy based on the Quickfinger Luc (QFL) trading methodology. It identifies breakdown buying opportunities below established price base levels and enters mean-reversion trades. The strategy includes multi-safety order DCA scaling,

Strategy v5 Mean reversionSupport & resistance Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of 3C QFL Mean Reversal

ATOM 1m scalp HK

by dearvn
43 stars

This overlay strategy targets one-minute ATOM scalps. It tracks pivot highs and lows as resistance and support, compares a three-period EMA with a multi-stage smoothed close, and flags long or short when price crosses that curve in the matching direction. Dail

Strategy v5 ScalpingSupport & resistance Repaints
Updated 2 years ago · None stated GitHub repository of ATOM 1m scalp HK

More Scalping scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers