Strategy · Pine Script v5 · On the chart

CryptoSwarmStrategy

by aegntic

CryptoSwarmStrategy is a chart overlay strategy that enters long when a fast EMA crosses above a slow EMA, RSI is below the oversold level, and volume exceeds its 20-bar average.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code47
Settings5inputs
LicenceMIT
Last update6 months ago6 Apr 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

47 lines of Pine Script v5 from _archive/root-scripts/tradingview_strategy.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

tradingview_strategy.pine
//@version=5
strategy("CryptoSwarmStrategy", overlay=true, pyramiding=1)

// Input parameters
fast_length = input.int(12, "Fast EMA Length")
slow_length = input.int(26, "Slow EMA Length")
rsi_length = input.int(14, "RSI Length")
rsi_oversold = input.int(30, "RSI Oversold")
rsi_overbought = input.int(70, "RSI Overbought")

// Calculate indicators
fast_ema = ta.ema(close, fast_length)
slow_ema = ta.ema(close, slow_length)
rsi = ta.rsi(close, rsi_length)
volume_sma = ta.sma(volume, 20)

// Entry conditions
long_condition = ta.crossover(fast_ema, slow_ema) and rsi < rsi_oversold and volume > volume_sma
short_condition = ta.crossunder(fast_ema, slow_ema) and rsi > rsi_overbought and volume > volume_sma

// Exit conditions
long_exit = rsi > rsi_overbought or ta.crossunder(fast_ema, slow_ema)
short_exit = rsi < rsi_oversold or ta.crossover(fast_ema, slow_ema)

// Webhook message
webhook_message = '{"symbol": "' + syminfo.ticker + '", "action": "{{strategy.order.action}}", "price": {{strategy.order.price}}, "timeframe": "' + timeframe.period + '", "strategy": "CryptoSwarmStrategy", "indicators": {"rsi": ' + str.tostring(rsi) + ', "volume_ratio": ' + str.tostring(volume/volume_sma) + '}}'

// Strategy logic
if (long_condition)
    strategy.entry("Long", strategy.long, alert_message=webhook_message)
    
if (short_condition)
    strategy.entry("Short", strategy.short, alert_message=webhook_message)
    
if (long_exit and strategy.position_size > 0)
    strategy.close("Long", alert_message=webhook_message)
    
if (short_exit and strategy.position_size < 0)
    strategy.close("Short", alert_message=webhook_message)

// Plot indicators
plot(fast_ema, color=color.blue, title="Fast EMA")
plot(slow_ema, color=color.red, title="Slow EMA")

// Plot signals
plotshape(long_condition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(short_condition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)

Overview

CryptoSwarmStrategy enters short on the opposite EMA cross with RSI above overbought and the same volume filter. It closes longs when RSI becomes overbought or the fast EMA crosses back under the slow EMA, and closes shorts on the reverse conditions. Length and RSI threshold inputs change the signals. It plots both EMAs and triangle markers on the price chart. There is no stop loss.

Details

Published by

aegntic on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Moving averages, Oscillators & momentum, Volume

Markets

Crypto

Timeframes

Any timeframe

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
Fast EMA Lengthint12fast_length
Slow EMA Lengthint26slow_length
RSI Lengthint14rsi_length
RSI Oversoldint30rsi_oversold
RSI Overboughtint70rsi_overbought
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

106 stars

This strategy enters long on an outside bar when the candle is bullish, the Klinger Volume Oscillator is positive, and price is above a Hull moving average. It enters short on an inside bar when the candle is bearish, the oscillator is negative, and price is b

Strategy v4 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of Advanced OutSide Forex strategy

CombinedBinHAndClucV8

by viktors1982
36 stars

This strategy trades on the price chart using multiple indicators. It enters long positions when price dips meet conditions on Bollinger Bands 40 and 20, RSI, MFI, volume and other thresholds. It exits at custom ROI profit levels based on RSI or after timeout

Strategy v4 Oscillators & momentumMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of CombinedBinHAndClucV8
12 stars

This strategy enters long when a fast EMA crosses above a slow EMA and RSI, ADX, and volume all clear their thresholds. It sizes the order from a percentage of equity and an ATR stop distance, then sets a partial profit target at a multiple of that risk. After

Strategy v5 TrendMoving averages
Updated 4 months ago · None stated GitHub repository of BTC 4H Institutional Trend

Combined Strategy

by Dropio12
7 stars

This strategy plots buy and sell markers on the price chart by combining a fast and slow ALMA crossover with a simple close-to-close momentum check. A long marker appears when the fast ALMA crosses above the slow ALMA and momentum is positive. A short marker a

Strategy v5 TrendOscillators & momentum
Updated 2 years ago · None stated GitHub repository of Combined Strategy

Antigravity Superstar

by eltonaguiar
4 stars

This strategy draws on the price chart and combines a triple EMA stack, a volume spike with a minimum price move, and a MACD line-signal crossover. It enters long or short only when at least the chosen number of those three signals agree, with an optional RSI

Strategy v6 TrendMoving averages
Updated today · None stated GitHub repository of Antigravity Superstar
3 stars

This strategy plots long and short markers on the price chart. It builds a composite index from RSI change and a short RSI average, then requires that index, a one-minute cumulative volume delta, and a relative volatility index to agree. EMA, SMA, and VWAP rel

Strategy v5 Oscillators & momentumVolume Repaints
Updated 2 years ago · GPL-3.0 GitHub repository of Composite RVI CVD Strategy

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