Strategy · Pine Script v5 · On the chart

Tiered Exit (Memecoin)

by muammeryldrm42

This strategy enters long trades when a fast EMA crosses above a slow EMA.

View on GitHub

Repaints

GitHub stars7on the repository
Pine versionv5runs as is
Lines of code83
Settings11inputs
LicenceMIT
Last update3 months ago8 Jul 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

83 lines of Pine Script v5 from public/code/memecoin__tiered_exit.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

memecoin__tiered_exit.pine
//@version=5
// =====================================================
// Tiered Exit Strategy (Memecoin) - Strategy Lab
// =====================================================
// Tiered profit-taking: partial exits at +50% / +150% / +300% levels,
// moonbag tracking via trailing stop, hard SL protection.
// =====================================================

strategy("Tiered Exit (Memecoin)", overlay=true,
         default_qty_type=strategy.percent_of_equity, default_qty_value=100,
         pyramiding=0, calc_on_every_tick=true)

// ============ ENTRY (basit momentum trigger) ============
useSimpleEntry = input.bool(true, "Use simple momentum entry")
emaFast = input.int(9, "EMA Fast")
emaSlow = input.int(21, "EMA Slow")

// ============ TIERED EXIT PARAMS ============
tp1Pct   = input.float(50.0, "TP1 % gain") / 100
tp2Pct   = input.float(150.0, "TP2 % gain") / 100
tp3Pct   = input.float(300.0, "TP3 % gain") / 100
sell1    = input.float(30.0, "TP1 sell %") / 100
sell2    = input.float(30.0, "TP2 sell %") / 100
sell3    = input.float(30.0, "TP3 sell %") / 100
hardSL   = input.float(25.0, "Hard SL %") / 100
trailDD  = input.float(35.0, "Trailing drawdown from ATH %") / 100

ef = ta.ema(close, emaFast)
es = ta.ema(close, emaSlow)
entrySig = useSimpleEntry and ta.crossover(ef, es)

if entrySig and strategy.position_size == 0
    strategy.entry("Long", strategy.long)

// ============ POSITION TRACKING ============
var float entryPrice = na
var float athPrice    = na
var bool  tp1Done     = false
var bool  tp2Done     = false
var bool  tp3Done     = false

if strategy.position_size > 0 and na(entryPrice)
    entryPrice := strategy.position_avg_price
    athPrice   := close
    tp1Done := false
    tp2Done := false
    tp3Done := false

if strategy.position_size > 0
    athPrice := math.max(athPrice, high)

// ============ TIERED EXITS ============
if strategy.position_size > 0 and not na(entryPrice)
    pctChange = (close - entryPrice) / entryPrice

    // Hard SL
    if pctChange <= -hardSL
        strategy.close("Long", comment="Hard SL")
        entryPrice := na

    // Trailing stop (in profit zone)
    ddFromAth = (athPrice - close) / athPrice
    if pctChange > 0.30 and ddFromAth >= trailDD
        strategy.close("Long", comment="Trail Stop")
        entryPrice := na

    // TP kademeleri
    if not tp1Done and close >= entryPrice * (1 + tp1Pct)
        strategy.close("Long", qty_percent=sell1 * 100, comment="TP1 +50%")
        tp1Done := true
    if not tp2Done and close >= entryPrice * (1 + tp2Pct)
        strategy.close("Long", qty_percent=sell2 * 100, comment="TP2 +150%")
        tp2Done := true
    if not tp3Done and close >= entryPrice * (1 + tp3Pct)
        strategy.close("Long", qty_percent=sell3 * 100, comment="TP3 +300%")
        tp3Done := true

if strategy.position_size == 0
    entryPrice := na

plot(ef, "EMA Fast", color.aqua)
plot(es, "EMA Slow", color.orange)
plotshape(entrySig, "Entry", shape.triangleup, location.belowbar, color.lime)

Overview

Position risk and profits are managed through tiered exit stages: three custom percentage-based profit targets with partial exits, a hard percentage stop loss, and a trailing drawdown exit trigger calculated from the peak high since trade entry. Indicators and signal arrows plot directly on the price chart. The strategy recalculates on every tick, which means signals can fluctuate on open live bars before closing.

Details

Published by

muammeryldrm42 on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages

Markets

Crypto

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • The strategy enters trades without a stop loss

Topics

cryptofuturessodexsosovaluestrategyvaluechain

Settings

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

SettingTypeDefaultVariable
Use simple momentum entrybooltrueuseSimpleEntry
EMA Fastint9emaFast
EMA Slowint21emaSlow
TP1 % gainfloat50.0tp1Pct
TP2 % gainfloat150.0tp2Pct
TP3 % gainfloat300.0tp3Pct
TP1 sell %float30.0sell1
TP2 sell %float30.0sell2
TP3 sell %float30.0sell3
Hard SL %float25.0hardSL
Trailing drawdown from ATH %float35.0trailDD
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

Doge SMA

by hackingthemarkets
474 stars

Doge SMA is a long-only moving-average crossover strategy drawn on the price chart. It calculates a fast and a slow simple moving average of close and enters a long position when the fast average crosses above the slow average, but only inside a user-defined s

Strategy v4 TrendMoving averages
Updated 4 years ago · None stated GitHub repository of Doge SMA

This strategy calculates and plots a fast Exponential Moving Average (EMA) and a slow EMA directly on the main price chart. It enters long trades when the fast EMA crosses above the slow EMA and exits when the fast EMA crosses below the slow EMA. Inputs allow

Strategy v6 TrendMoving averages
Updated today · AGPL-3.0 GitHub repository of Forven S01508 — Simple EMA20/50 Cross
330 stars

2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the

Strategy v4 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of 2 EMA/SMA + RSI Strategy [Alorse]

Acrypto - Weighted Strategy

by AlbertoCuadra
318 stars

This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can

Strategy v5 TrendOscillators & momentum
Updated 3 years ago · Custom licence GitHub repository of Acrypto - Weighted Strategy
257 stars

This strategy calculates dynamic support and resistance levels using pivot highs and lows alongside a custom smoothed trend filter and a 3-period EMA. It identifies entry opportunities when price breaks out relative to the trend filter and short-term EMA cross

Strategy v5 TrendSupport & resistance Repaints
Updated 6 weeks ago · None stated GitHub repository of 30s - ES 1m Strategy Candle Bar

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