Strategy · Pine Script v5 · On the chart

STRG One Bar Pursuit

by harryguiacorn· code credited to FxCloudTrader

The STRG One Bar Pursuit strategy identifies single-bar momentum reversals by monitoring shifts between bullish and bearish candlesticks starting from the year 2024.

View on GitHub

GitHub stars219on the repository
Pine versionv5runs as is
Lines of code59
Settings3inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago8 May 2025

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

59 lines of Pine Script v5 from STRG One Bar Pursuit.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

STRG One Bar Pursuit.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © FxCloudTrader

//@version=5
strategy("STRG One Bar Pursuit", overlay=true, margin_long=100, margin_short=100)


// Input for ATR length and multiplier for entry and stop
atrLength = input.int(14, title="ATR Length")
atrMultiplierEntry = input.float(1, title="ATR Multiplier for Entry")
atrMultiplierStop = input.float(1, title="ATR Multiplier for Stop")

// Calculate ATR
atr = ta.atr(atrLength)

plot(atr)

// Define the bullish and bearish conditions
bullishBar = close > open  and year >= 2024
bearishBar = close < open and year >= 2024

// Check for long entry condition
longCondition = bearishBar[1] and bullishBar

// Define long entry price (limit order) and stop loss
longProfitPrice = close[1] + atrMultiplierEntry * atr[1]
longStopPrice = longProfitPrice - atrMultiplierStop * atr[1]

// Check for short entry condition
shortCondition = bullishBar[1] and bearishBar

// Define short entry price (limit order) and stop loss
shortProfitPrice = close[1] - atrMultiplierEntry * atr[1]
shortStopPrice = shortProfitPrice + atrMultiplierStop * atr[1]

var trade_direction = 0

// Execute long trade
if longCondition
    strategy.entry("Long", strategy.long, qty = 2)
    strategy.exit("Long Exit", "Long", stop=longStopPrice) //, limit = longProfitPrice, qty = 1
    log.info("longProfitPrice {0}", longProfitPrice)
    trade_direction := 1

// Execute short trade
if shortCondition
    strategy.entry("Short", strategy.short, qty = 2)
    strategy.exit("Short Exit", "Short", stop=shortStopPrice) //, limit = shortProfitPrice, qty = 1
    trade_direction := -1

if bearishBar and trade_direction == 1
    // strategy.exit("Long Exit", "Long")
    strategy.close_all("Long Exit")
    trade_direction := 0

if bullishBar and trade_direction == -1
    // strategy.exit("Short Exit", "Short")
    strategy.close_all("Short Exit")
    trade_direction := 0

Overview

STRG One Bar Pursuit enters a long position when a bullish candle follows a bearish candle and enters a short position when a bearish candle follows a bullish candle. Exits rely on dynamic Average True Range (ATR) stop-loss levels alongside immediate position closure upon detecting an opposing candle. Settings allow users to adjust the ATR length, ATR entry multiplier, and ATR stop multiplier.

Details

Published by

harryguiacorn on GitHub

Code credit

FxCloudTrader, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Candlestick patterns, Mean reversion

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

bollingerbollinger-bandbollinger-bandsichimokuichimoku-cloudichimoku-indicatorpinepinescriptpinescript-guidespinescript-indicators

Settings

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

SettingTypeDefaultVariable
ATR Lengthint14atrLength
ATR Multiplier for Entryfloat1atrMultiplierEntry
ATR Multiplier for Stopfloat1atrMultiplierStop
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

330 stars

Exceeded Candle [Alorse] is a mean-reversion strategy that identifies candlestick engulfing patterns combined with Bollinger Bands filters. It enters a long position when a green candle surpasses the body of the previous red candle while price is below the mid

Strategy v4 Mean reversionCandlestick patterns
Updated 2 months ago · None stated GitHub repository of Exceeded candle [Alorse]
285 stars

Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish

Strategy v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Strategy

A Strategy for Leledec

by hasnocool
106 stars

This Pine Script strategy identifies major and minor Leledec exhaustion bars by tracking consecutive price bar comparisons against past closes and checking local extremes over set lookback lengths. It overlays visual markers directly on the price chart for det

Strategy v4 Mean reversionCandlestick patterns
Updated 2 years ago · GPL-3.0 GitHub repository of A Strategy for Leledec

BodyOutlier A003

by ruckard
13 stars

BodyOutlier A003 is a mean-reversion trading strategy designed for automated execution via Zignaly alerts. It identifies candlestick body outliers to place limit orders, buying at the low of unusually large bullish candles or selling at the high of large beari

Strategy v5 Candlestick patternsMean reversion
Updated 1 year ago · None stated GitHub repository of BodyOutlier A003

Markov Strategy

by Rohanom
9 stars

Markov Strategy is a mean-reversion quantitative strategy inspired by streak-based Markov chain analysis. Applied directly to the price chart, it monitors price action for consecutive downward closes. The strategy enters a long position after detecting six con

Strategy v5 Mean reversionCandlestick patterns
Updated 1 year ago · MIT GitHub repository of Markov Strategy

Quick Flip Scalper

by TradersPost
218 stars

This strategy executes an opening-range liquidity fade based on the first candle of a session. It qualifies the opening range against the daily ATR to confirm manipulation or liquidity spikes. If qualified, it searches for reversal candlestick patterns, such a

Strategy v6 Sessions & timeCandlestick patterns
Updated 3 months ago · None stated GitHub repository of Quick Flip Scalper

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