A long and short strategy using a long simple moving average with bands set a chosen number of standard deviations above and below it, 350 bars by default. It goes long when price closes above the upper band and exits when price falls back under the average; i
A strategy-type script for the price chart that marks the high, low and midpoint of the first part of each session, set by start hour and minute inputs, and alerts when price crosses above the high or below the low. It also plots VWAP and a 50-period EMA, pivo
This strategy implements custom trailing stop logic driven by momentum signals. It calculates first- and second-order price momentum, entering long or short via stop orders above or below the current bar when momentum is consistently positive or negative. A cu
A two-sided mean reversion strategy built on a very short RSI and a 200-period SMA. Longs are taken after a deeply oversold RSI reading while price is above the SMA, and shorts after an overbought reading below it, with RSI-based closing rules. Stop loss, take
The Hammers & Stars Strategy identifies hammer and star candlestick patterns on the price chart to generate buy and sell signals. It calculates stop loss as ATR multiplied by a user-defined multiplier and sets take profit using the risk-reward ratio. Fib level
This long-only strategy plots Bollinger Bands, 20 bars and 2.5 deviations by default, along with a 10 and a 50 period EMA and a background that shades the EMA trend. When flat, it buys after the close crosses back above the lower band, and it closes the positi
This strategy uses a 14-period RSI with fixed thresholds. It goes long when RSI crosses above 60 and short when it crosses below 40. Each side has a percentage trailing stop, two percent by default, that follows the close and only moves in the trade's favour;
A long-only strategy that buys when the 14-bar RSI is below 30 inside a chosen date range. It closes all positions when price reaches a percentage profit target or falls to a percentage stop loss, checked on closes. The order size doubles after each close, a p
A long-only strategy designed for the 4-hour chart. It averages open, high, low and close, smooths that with a mid-term SMA and builds a relative strength line from the gap between price and the SMA. When the slope of that line turns positive it places a limit
A strategy that combines several filters on one chart. Components include an ignition bar marker based on a candle body retracement percentage, fractal detection, three configurable moving averages, an RSI with overbought and oversold levels, a trading range l
This Pine v5 strategy calculates a 20-period Bollinger Band basis and places stop-style entry orders at the basis. A long order is placed when the close crosses above the basis and a short order when it crosses below, and pending orders are cancelled on bars w
A Pine v4 strategy that plots a 30-period exponential moving average of the close in orange on the price chart. It goes long when a green candle opens above the average and short when a red candle opens below it, closing each position when the opposite signal
This strategy is a bare template that crosses a fast 15-period and a slow 45-period exponential moving average of the bar midpoint. It enters long on an upward cross and short on a downward cross, reversing between the two, and starts trading from a date set b
This strategy enters long when a bullish candle closes above an EMA and its upper wick is no larger than a set percent of the candle range, and short on the opposite bearish setup. It closes a long after price rises a small fixed fraction above the entry bar o
This strategy draws on the price chart and combines Stochastic RSI, the Money Flow Index, and an exponential moving average to open long or short trades. Longs use the lower oscillator thresholds and shorts use the upper ones, with direction limited to longs,
This strategy plots a fast and a slow simple moving average on the price chart. It enters a long position when the fast average crosses above the slow average and closes that long when the fast average crosses below the slow average. Percentage take profit and
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
This Pine Script strategy demonstrates the usage of bar state variables by highlighting the chart background color. It evaluates whether the current candle is the final bar on the chart using the barstate.islast condition and applies a silver background color
This strategy executes trades on the current chart based on daily percentage price changes of an external ticker (GOOG). It fetches the daily open and close prices of the reference symbol to compute its intraday price change ratio. When the reference asset dro
This script serves as a unit testing suite implemented in Pine Script to validate components of a 5-minute Bitcoin scalping strategy. It establishes a custom test runner framework using user-defined types to record and evaluate mock modules. Tested modules inc
This strategy identifies trend direction from Donchian Channel breakouts and executes trades on pullbacks toward the channel midpoint. A new breakout beyond the previous channel bands sets a bullish or bearish trend state. When price retraces to or across the
This strategy overlays the price chart to execute long and short trades on BTCUSDT. It requests multi-timeframe data across daily, 3-minute, 5-minute, 8-minute, and 10-minute periods to generate signals alongside VWMA volatility bands and smoothed moving avera
This strategy draws on the price chart and trades both directions. It enters long when a variable moving average crosses above the Optimized Trend Tracker while price is above a fast EMA, and short on the opposite cross below a slower EMA. Entries are blocked
SMAOffsetProtectOptV1 is a long-only price-chart strategy that buys when close falls below an offset SMA or EMA and either the Elliott Wave Oscillator is above its high threshold with RSI below a limit, or the oscillator is below its low threshold. It exits wh
This strategy builds Bollinger bands from a simple moving average and the standard deviation of the close. It opens a short when price crosses above the upper band and the 14-period RSI is above 80, and opens a long when price crosses below the lower band and
This trend-following strategy plots Donchian channels and trade signals directly on the price chart. It enters long or short positions upon Donchian channel breakouts and scales in with accelerated pyramiding every fraction of the Average True Range. Position
Crossing EMAs A is an automated strategy that overlays directly on the price chart. Despite its title referencing exponential moving averages, the script calculates fourteen-period and twenty-eight-period simple moving averages. It enters a long position when
This script executes an exported series of hardcoded backtest orders on the price chart. Each trade is triggered and closed at predefined Unix millisecond timestamps with fixed order sizes and execution price limits, simulating a vanilla RSI strategy on the 15
NFI v7.2 is a Pine Script adaptation of the popular NostalgiaForInfinity algorithmic trading strategy originally built for Freqtrade. It analyzes price action and exponential moving average metrics across both base and higher informative timeframes, incorporat
The Stochastic Divergence Strategy calculates the Stochastic oscillator (%K and %D) to identify regular bullish and bearish divergence patterns against price pivots. It plots the oscillator and divergence lines in a separate indicator pane. Entries trigger on
Dual Moving Average is a Pine Script v4 strategy that overlays the price chart. The shown code declares a strategy with fixed quantity, cash commission, slippage, and calculation on every tick. Inputs set the price source, a start and end date, a symbol that d
This strategy calculates volatility-based Chandelier Exit bands using the Average True Range and high/low extremes, paired with an optional exponential moving average trend filter. It enters long when the close crosses above the long Chandelier line while abov
This strategy calculates a Supertrend line based on Average True Range parameters to identify market trends. It combines Supertrend trend reversals with an initial percentage-based stop loss and a dynamic trailing stop loss. Trades are taken according to the s
This overlay strategy combines three distinct SuperTrend levels with multiple moving averages and volume profile analytics on the main price chart. It calculates trend directions using three configurable ATR periods and multipliers alongside SMA, EMA, and HMA
Calculates three-bar Fair Value Gaps (FVG) and filters them using Average True Range. When price mitigates the FVG midpoint, the strategy enters a position in the direction of the gap, provided an optional EMA trend filter is satisfied. Exits are defined by an
This strategy plots a daily VWAP, a 90-period simple moving average from the one-hour chart, and a 50-period EMA plus a 90-period SMA from the 15-minute chart on the price chart. It enters long when VWAP crosses above the one-hour average, or while VWAP remain
This strategy serves as a diagnostic probe testing the initial value behavior of volume-weighted average price calculations across session boundaries. It evaluates default VWAP, explicit daily anchor VWAP, and custom bar-indexed anchor VWAP. Upon encountering
RG Structure is a pivot-constrained break-and-retest strategy that calculates dynamic trendlines, market structure changes, and regime states on the price chart. It identifies support and resistance lines through pivot points and evaluates break-and-retest sig
Cerebr Centauri Demo is a multi-indicator trading strategy overlaying conditions directly on the price chart. It combines lower-timeframe and higher-timeframe inputs across moving averages, Stochastic oscillators, RSI, and MACD to generate trade signals. Trade
This long-only trend-following strategy plots a 20-period short EMA and a 50-period long EMA directly on the price chart. It triggers long entries when the short EMA is above the long EMA, price breaks above a recent pivot high, and specific price action condi
This overlay strategy is written for MES and ES five-minute charts. It calculates a fast and slow EMA, a 200-period trend EMA, session VWAP, RSI, ATR, and a volume moving average, and it can restrict trading to an exchange-time session. Inputs set RSI extremes
This strategy evaluates EMA momentum crossovers filtered by an RSI oscillator. It enters a long position when a fast EMA crosses above a slow EMA while RSI remains above 40. Conversely, it enters a short position when the fast EMA crosses below the slow EMA wh
This strategy identifies Bitcoin price trends using fast and slow EMA crossovers filtered by RSI and a 200 EMA. It plots the EMAs and entry signals on the price chart. Bullish crossovers open long positions with ATR-based stop loss and take profit. Bearish cro
This strategy overlays the price chart and sizes cash positions from account equity using a selectable Phase 1 or Phase 2 risk percent. It tracks net profit by calendar day and blocks new risk once the phase daily-loss limit is reached. Swing sensitivity sets
This long-only strategy plots an asymmetric ATR channel around a rolling moving average on the price chart. It enters long when a confirmed close breaks above the upper band and exits when a confirmed close breaks below the lower band. An optional setting exit
SMC Order Block + FVG is an intraday strategy combining market structure breaks, order blocks, and fair value gaps. It identifies breaks of structure using pivot points, isolates order blocks following strong ATR-based impulses, and tracks fair value gaps. Lon
This strategy demonstrates fixed-fraction position sizing based on a set percentage of account equity at risk. It calculates trade quantity dynamically using an Average True Range (ATR) stop distance. Long entries trigger when price crosses above a 50-period s
Improvisando [Alorse] is a price-chart strategy that plots three exponential moving averages and a TTM Squeeze-style oscillator. It opens a long when price is above all three averages and the oscillator is rising while still below zero. Shorts use the opposite
Third-party code. ForexR lists open-source Pine scripts from GitHub; it did not write, test or endorse them, and their summaries are generated automatically from each script's code and README. Indicators describe the past, and a strategy's backtest can look better than live trading. Check a script on a demo account before you rely on it. CFDs and leveraged forex are complex instruments with a high risk of losing money rapidly.
Learn to Use Pine Scripts
Free, plain-English guides: add a script to TradingView, read what it does, test it and avoid the common traps.