Strategy · Pine Script v5 · Own pane

TradersPost High-Low Range Strategy

by TradersPost

This strategy identifies high-volatility expansion bars by comparing the high-low range to a moving average plus standard deviation threshold.

View on GitHub

GitHub stars6on the repository
Pine versionv5runs as is
Lines of code33
Settings3inputs
LicenceNone statedfile: MPL-2.0
Last update1 year ago20 Dec 2024

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

33 lines of Pine Script v5 from strategies/HighLowRangeTrendFollowing.pinescript, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

HighLowRangeTrendFollowing.pinescript
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © TradersPostInc
// Visit https://traderspost.io to automate your TradingView strategies at top brokers TD Ameritrade, TradeStation, and Alpaca.

// Thesis: 
// We're searching for big range bars and if the momentum is in a positive direction, then we buy.
// When a range bar is found and the trend is in the opposite direction, we sell.
// Full credit to Kevin Davey for his work on basic strategies.

//@version=5
strategy("TradersPost High-Low Range Strategy", overlay=false, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

rrange = high-low
lookback = input.int(2, minval=1, title="Lookback")
xr = input.int(10, minval=1, title="Range Length")
mult = input.float(2.0, minval=0.001, maxval=50, title="SD")

computation = mult * ta.stdev(rrange, xr) + ta.sma(rrange, xr)
cond1 = rrange > computation

plot(rrange, title="Range H-L", style=plot.style_columns)
plot(computation, title="H-L SD", style=plot.style_line, color=color.orange)
plot(close - close[lookback], title="Close Direction", color=close > close[lookback] ? color.green : color.red, style=plot.style_histogram)

longCondition =  cond1 and close > close[lookback]
if (longCondition)
    strategy.entry("Long entry", strategy.long)
    alert("Long entry", freq = alert.freq_once_per_bar_close)

shortCondition = cond1 and close < close[lookback]
if (shortCondition)
    strategy.close_all("Close all positions", immediately = true)
    alert("Close all positions", freq = alert.freq_once_per_bar_close)

Overview

When range expansion occurs, it checks momentum over a specified lookback period. It opens a long position if the current close is above the close from the lookback period, and closes all open positions if the close is below it. User inputs adjust the momentum lookback, range length, and standard deviation multiplier. The strategy plots range columns, threshold lines, and close direction in a separate pane. It has no stop loss mechanism.

Details

Published by

TradersPost on GitHub

Type

Strategy, Pine Script v5

Draws

Separate pane below the chart

Category

Volatility & bands, Oscillators & momentum, Trend, Breakout

Markets

Any symbol

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
Lookbackint2lookback
Range Lengthint10xr
SDfloat2.0mult
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

16 stars

This strategy trades Donchian channel breakouts on the price chart and exits on a shorter Donchian channel. It sizes each unit from a percentage of equity and an ATR-based initial stop, then adds units as price moves a set ATR distance, up to a maximum unit co

Strategy v6 TrendBreakout
Updated 11 months ago · None stated GitHub repository of Seykota Alt 16: Anti-Chop Filters

GEO P Momentum Strategy

by newsfriend
2 stars

Implements a rule-based momentum trading strategy that detects Bollinger Band challenges followed by synchronized trendline or range breakouts on the price chart. Entries trigger under configurable strictness modes using multi-timeframe Tide and Wave alignment

Strategy v6 Oscillators & momentumVolatility & bands
Updated 8 weeks ago · None stated GitHub repository of GEO P Momentum Strategy

This strategy evaluates multi-factor breakout confluence using a customized scoring system on the price chart. It checks Minervini-style Volatility Contraction Pattern trend templates, TTM squeeze volatility compression, volume dry-up with OBV accumulation, mo

Strategy v6 BreakoutVolatility & bands
Updated 2 months ago · None stated GitHub repository of TnSovereign Breakout Confluence V6

Volume Breakout Strategy

by kanylbullen
1 stars

This strategy identifies breakouts using Keltner Channels combined with volume spike filters, ADX trend strength, RSI thresholds, and an optional EMA trend direction filter. It triggers long entries when price crosses above the upper channel and short entries

Strategy v5 BreakoutTrend Repaints
Updated 6 days ago · None stated GitHub repository of Volume Breakout 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