PipAtlas Strategy Template provides a standard framework for Pine Script v5 strategies, featuring dual moving average crossover entry logic, ATR-based stop losses, fixed risk-reward target exits, and risk-adjusted position sizing.
//@version=5
// PipAtlas strategy template (Pine v5) — https://pipatlas.com/learn/conversions
// A skeleton with the four things every strategy needs before it means anything:
// a rule for entry, a rule for exit, a stop that is defined before the trade, and a
// position size derived from risk — not from conviction. Replace the placeholder
// condition with your own idea and change nothing else until it is tested.
// Education only, never financial advice. MIT licensed.
strategy("PipAtlas Strategy Template", overlay = true,
initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 1,
commission_type = strategy.commission.cash_per_order, commission_value = 0.35,
slippage = 2, calc_on_every_tick = false)
riskPct = input.float(1.0, "Risk per trade (% of equity)", step = 0.25)
atrMult = input.float(2.0, "Stop = ATR x", step = 0.25)
rewardMult= input.float(2.0, "Target = stop x", step = 0.25)
fastLen = input.int(20, "Fast average")
slowLen = input.int(50, "Slow average")
// ---- the idea (replace this block) -------------------------------------------
fast = ta.ema(close, fastLen)
slow = ta.ema(close, slowLen)
longIdea = ta.crossover(fast, slow)
shortIdea = ta.crossunder(fast, slow)
// ------------------------------------------------------------------------------
atr = ta.atr(14)
stopDist = atr * atrMult
longStop = close - stopDist
shortStop = close + stopDist
longTgt = close + stopDist * rewardMult
shortTgt = close - stopDist * rewardMult
// size from the distance to the stop, so a wider stop is a smaller position
riskCash = strategy.equity * riskPct / 100
qtyLong = stopDist > 0 ? riskCash / stopDist : 0
qtyShort = qtyLong
if longIdea and strategy.position_size == 0
strategy.entry("Long", strategy.long, qty = qtyLong)
strategy.exit("Long exit", from_entry = "Long", stop = longStop, limit = longTgt)
if shortIdea and strategy.position_size == 0
strategy.entry("Short", strategy.short, qty = qtyShort)
strategy.exit("Short exit", from_entry = "Short", stop = shortStop, limit = shortTgt)
plot(fast, "Fast", color = color.new(color.teal, 0))
plot(slow, "Slow", color = color.new(color.orange, 0))
plot(strategy.position_size, "Position size", display = display.data_window)
// the honest part: a backtest on one symbol and one timeframe is one sample.
// Costs, slippage and swap are assumptions — check them against your own broker's numbers.
Overview
By default, it calculates 20-period and 50-period exponential moving averages, plotting them directly on the price chart pane. Position sizes are dynamically computed from a percentage of total equity relative to the stop loss distance.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Risk per trade (% of equity)
float
1.0
riskPct
Stop = ATR x
float
2.0
atrMult
Target = stop x
float
2.0
rewardMult
Fast average
int
20
fastLen
Slow average
int
50
slowLen
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.
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
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
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
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
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
EMA Crossover Strategy plots a fast and a slow exponential moving average on the price chart. It treats a confirmed fast-over-slow cross as a long condition and a confirmed cross under as a short condition. Position size is a percentage of equity. Optional per