Strategy · Pine Script v6 · On the chart

BTC 1min CCI Reversal

by PETERSAMUELOPS12· code credited to Gotrade

A one-minute Bitcoin strategy built on a short five-period CCI of the typical price.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code135
Settings5inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago25 May 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

135 lines of Pine Script v6 from pinescript/btcusd-1min.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

btcusd-1min.pine
// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Gotrade

//@version=6
// ── Fill timing ───────────────────────────────────────────────────────────────
// process_orders_on_close=false (default) → fills at NEXT candle OPEN
// process_orders_on_close=true           → fills at CURRENT candle CLOSE
// Change the parameter below to switch between the two modes.
strategy("BTC 1min – CCI Reversal", overlay=true,
         default_qty_type=strategy.percent_of_equity, default_qty_value=100,
         initial_capital=1000,
         commission_type=strategy.commission.percent, commission_value=0.04,
         process_orders_on_close=false,   // set true for "fill at current close"
         calc_on_every_tick=false,
         pyramiding=0)                    // enforces ONE position at a time

// ═══════════════════════════════════════════════════════════════════════════════
// INPUTS
// ═══════════════════════════════════════════════════════════════════════════════
grp0 = "CCI Settings"
cciLen   = input.int(5,     "CCI Length",          minval=1,  group=grp0)
cciUpper = input.float(100, "Upper level (long)",  minval=1,  group=grp0,
               tooltip="CCI crossover above this level triggers a long entry.")
cciLower = input.float(-100,"Lower level (short)", maxval=-1, group=grp0,
               tooltip="CCI crossunder below this level triggers a short entry.")

grp1 = "Trade Direction"
allowLong  = input.bool(true, "Allow Long  (buy)",  group=grp1)
allowShort = input.bool(true, "Allow Short (sell)", group=grp1)

// ═══════════════════════════════════════════════════════════════════════════════
// CCI CALCULATION
// ═══════════════════════════════════════════════════════════════════════════════
// Standard CCI uses typical price (HLC/3)
cci5 = ta.cci(hlc3, cciLen)

// ═══════════════════════════════════════════════════════════════════════════════
// SIGNALS
// ═══════════════════════════════════════════════════════════════════════════════
// Bullish: CCI crosses above +100  →  long entry (or flip from short)
// Bearish: CCI crosses below -100  →  short entry (or flip from long)
cciBullCross = ta.crossover(cci5, cciUpper)
cciBearCross = ta.crossunder(cci5, cciLower)

// ═══════════════════════════════════════════════════════════════════════════════
// POSITION STATE
// ═══════════════════════════════════════════════════════════════════════════════
inLong  = strategy.position_size > 0
inShort = strategy.position_size < 0
flat    = strategy.position_size == 0

// ═══════════════════════════════════════════════════════════════════════════════
// ORDERS
// Rules:
//   • Only ONE position at any time (pyramiding=0 enforces this).
//   • CCI crosses above +100 AND not already long  → enter long
//       (if short, auto-reverses: closes short first, then opens long)
//   • CCI crosses below -100 AND not already short → enter short
//       (if long, auto-reverses: closes long first, then opens short)
//   • CCI crosses above +100 while already long  → IGNORE (hold)
//   • CCI crosses below -100 while already short → IGNORE (hold)
// ═══════════════════════════════════════════════════════════════════════════════
if cciBullCross and not inLong and allowLong
    strategy.entry("Long", strategy.long,
                   comment=inShort ? "FLIP L" : "OPEN L")

if cciBearCross and not inShort and allowShort
    strategy.entry("Short", strategy.short,
                   comment=inLong ? "FLIP S" : "OPEN S")

// ═══════════════════════════════════════════════════════════════════════════════
// PLOTS
// ═══════════════════════════════════════════════════════════════════════════════
// Entry signal shapes on the price chart
plotshape(cciBullCross and not inLong and allowLong,
          "Long Signal",  shape.triangleup,   location.belowbar,
          color.new(color.lime, 0), size=size.small)

plotshape(cciBearCross and not inShort and allowShort,
          "Short Signal", shape.triangledown, location.abovebar,
          color.new(color.red, 0), size=size.small)

// Hold signals (already in the correct direction — do nothing)
plotshape(cciBullCross and inLong,
          "Hold Long (ignore)", shape.circle, location.belowbar,
          color.new(color.gray, 40), size=size.tiny)

plotshape(cciBearCross and inShort,
          "Hold Short (ignore)", shape.circle, location.abovebar,
          color.new(color.gray, 40), size=size.tiny)

// Position background
bgcolor(inLong  ? color.new(color.green, 90) : na, title="Long position")
bgcolor(inShort ? color.new(color.red,   90) : na, title="Short position")

// ═══════════════════════════════════════════════════════════════════════════════
// DASHBOARD
// ═══════════════════════════════════════════════════════════════════════════════
var table dash = table.new(position.top_right, 2, 7,
     bgcolor=color.new(color.black, 55), border_width=1, border_color=color.new(color.gray, 60))

if barstate.islast
    cciCol  = cci5 > cciUpper ? color.lime : cci5 < cciLower ? color.red : color.silver
    posStr  = inLong ? "LONG" : inShort ? "SHORT" : "FLAT"
    posCol  = inLong ? color.lime : inShort ? color.red : color.gray
    netCol  = strategy.netprofit >= 0 ? color.lime : color.red
    pnlCol  = strategy.openprofit >= 0 ? color.lime : color.red

    table.cell(dash, 0, 0, "BTC CCI Reversal",  text_color=color.white,
               text_size=size.small, bgcolor=color.new(color.navy, 30))
    table.cell(dash, 1, 0, "1min",               text_color=color.white,
               text_size=size.small, bgcolor=color.new(color.navy, 30))

    table.cell(dash, 0, 1, "CCI(" + str.tostring(cciLen) + ")", text_color=color.silver, text_size=size.small)
    table.cell(dash, 1, 1, str.tostring(math.round(cci5, 2)),
               text_color=cciCol, text_size=size.small)

    table.cell(dash, 0, 2, "Levels",   text_color=color.silver, text_size=size.small)
    table.cell(dash, 1, 2, str.tostring(cciLower) + " / +" + str.tostring(cciUpper),
               text_color=color.silver, text_size=size.small)

    table.cell(dash, 0, 3, "Position", text_color=color.silver, text_size=size.small)
    table.cell(dash, 1, 3, posStr,     text_color=posCol, text_size=size.small)

    table.cell(dash, 0, 4, "Open P&L", text_color=color.silver, text_size=size.small)
    table.cell(dash, 1, 4, "$" + str.tostring(math.round(strategy.openprofit, 2)),
               text_color=pnlCol, text_size=size.small)

    table.cell(dash, 0, 5, "Net Profit", text_color=color.silver, text_size=size.small)
    table.cell(dash, 1, 5, "$" + str.tostring(math.round(strategy.netprofit, 2)),
               text_color=netCol, text_size=size.small)

    table.cell(dash, 0, 6, "Trades", text_color=color.silver, text_size=size.small)
    table.cell(dash, 1, 6, str.tostring(strategy.closedtrades),
               text_color=color.white, text_size=size.small)

Overview

A cross above the upper level opens or flips to a long, and a cross below the lower level opens or flips to a short, with each direction switchable. It holds a single position, sizes it as a percentage of equity and fills on the next candle open by default. The visible rules have no stop loss or take profit, so a position stays open until the opposite signal.

Details

Published by

PETERSAMUELOPS12 on GitHub

Code credit

Gotrade, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Oscillators & momentum, Scalping

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
CCI Lengthint5cciLen
Upper level (long)float100cciUpper
Lower level (short)float-100cciLower
Allow Long (buy)booltrueallowLong
Allow Short (sell)booltrueallowShort
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

5 Minute Scalp

by hasnocool
106 stars

This strategy overlays three exponential moving averages on the price chart, with periods of 9, 50, and 200. It calculates a MACD histogram from a 1-minute timeframe, applies Bollinger Bands to the histogram, and tracks two RSI oscillators of different lengths

Strategy v5 ScalpingMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 5 Minute Scalp

This strategy plots the previous daily high and low on the price chart and calculates the Andean oscillator bull and bear components with an exponential moving average signal. It looks for a bull or bear cross of that signal, then confirms the setup against re

Strategy v5 Oscillators & momentumSupport & resistance Repaints
Updated 3 years ago · MIT GitHub repository of Daily High/Low and Andean Oscillator Strategy
53 stars

This strategy trades EUR/USD on the price chart using a fast and slow exponential moving average crossover filtered by RSI. It enters long when the fast EMA crosses above the slow EMA while RSI is above 50 and below the overbought level, and enters short on th

Strategy v6 TrendMoving averages
Updated 2 months ago · MPL-2.0 GitHub repository of EUR/USD EMA9-21 + RSI Scalping Strategy
27 stars

LuxAlgo Hybrid Gold Scalper is a price-chart strategy aimed at gold. It stacks a fast, slow, trend and 200-period bias EMA to mark trend direction, then filters strength with RSI, ADX and an intraday VWAP. Swing highs and lows are marked from pivot length. Set

Strategy v5 TrendOscillators & momentum
Updated 5 months ago · None stated GitHub repository of LuxAlgo Hybrid Gold Scalper

Morning Scalp

by benso87
24 stars

This strategy tracks an opening session time range to establish directional bias and triggers pullback trades using Stochastic RSI. Once price breaks out of the initial range, it establishes a directional bias and enters when the Stochastic RSI crosses over in

Strategy v5 Sessions & timeBreakout
Updated 4 years ago · MPL-2.0 GitHub repository of Morning Scalp

This trend-following scalping strategy combines a moving average trend filter with the Absolute Strength Histogram indicator. It opens long positions when price is above a selectable baseline moving average and the histogram signals bullish momentum, and short

Strategy v5 TrendOscillators & momentum
Updated 1 year ago · None stated GitHub repository of Ruckard TradingZone Absolute Strength Histogram ATR

More strategys

Trade Your Charts With a Regulated Broker

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

Compare brokers