Strategy · Pine Script v5 · On the chart

APSAlgo Adaptive Pattern System

by Tradehook-org

A Pine v5 strategy that classifies the market as volatile, trending or ranging using ATR against its history and ADX thresholds.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code164
Settings15inputs
LicenceNone stated
Last update8 months ago16 Feb 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  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

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

In trending conditions it trades a 9 and 20 EMA crossover, and in ranging conditions it fades Bollinger Band extremes. Stops and targets are ATR multiples, with a wider stop and smaller size when volatile. Size is a percent of equity, pyramiding is off, and commission is included. Settings cover each regime's lengths and multipliers.

Details

Published by

Tradehook-org on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Mean reversion, Volatility & bands

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.

Settings

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

SettingTypeDefaultVariable
ADX Lengthinteger14adxLen
ADX Trend Thresholdfloat25.0adxThresholdTrend
ADX Range Thresholdfloat20.0adxThresholdRange
ATR Lengthinteger14atrLen
ATR Volatility Multiplierfloat1.5atrVolMult
ATR Historical Lengthinteger100atrHistLen
ATR Stop Loss Multiplierfloat3.0atrSLMult
ATR Take Profit Multiplierfloat6.0atrTPMult
Volatile SL Multiplier (Wider Stop)float4.5volatileSLMult
Volatile Position Size Multiplierfloat0.5volatileQtyMult
Percent of Equity per Tradefloat10.0equityPercent
Trend Fast MA Lengthinteger9fastMALen
Show all 15 settings
SettingTypeDefaultVariable
Trend Slow MA Lengthinteger20slowMALen
Range BB Lengthinteger20bbLen
Range BB StdDev Multiplierfloat2.0bbMult
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

This strategy calculates Bollinger Bands and Aroon oscillator values to identify mean-reversion opportunities. It enters a long position using full equity when the closing price crosses below the lower Bollinger Band while Aroon Up remains above a user-specifi

Strategy v5 Mean reversionVolatility & bands
Updated 2 months ago · None stated GitHub repository of Bollinger bands + Aroon [Alorse]

[TradersPost] Sick Sigma

by TradersPost
218 stars

Sick Sigma detects extreme statistical standard deviation moves (sigma events) to execute trades directly on the main price chart. The strategy supports both momentum and mean-reversion trading styles. Traders can configure calculation lookback periods, sigma

Strategy v6 Volatility & bandsMean reversion Repaints
Updated 3 months ago · None stated GitHub repository of [TradersPost] Sick Sigma

This strategy combines Volume Weighted Moving Average (VWMA) Bollinger Bands with 200-period and 50-period Exponential Moving Averages (EMAs). It identifies long trade opportunities when the 50 EMA is above the 200 EMA and price falls to or below the lower Fib

Strategy v4 TrendVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of Bollinger Band with Fib Golden Ratio (0.618)

Bollinger Bands Strategy

by cklose2000
105 stars

This strategy generates buy and sell signals based on Bollinger Band crossovers combined with a simple moving average trend filter. It enters a long position when price crosses above the lower band while trading above the SMA filter line, and enters a short po

Strategy v5 Volatility & bandsMoving averages
Updated 1 year ago · None stated GitHub repository of Bollinger Bands Strategy

Keltner Channel Trend - Eterna

by EternaHybridExchange
9 stars

This strategy plots a Keltner channel from an EMA basis and ATR bands on the price chart. It enters long when price crosses back above the lower band while trading above a slower trend EMA, and short when price crosses back below the upper band while below tha

Strategy v5 TrendVolatility & bands
Updated 7 months ago · MIT GitHub repository of Keltner Channel Trend - Eterna
5 stars

This strategy identifies shorting opportunities by calculating Fear and Greed zones based on price extremums relative to moving averages and standard deviation bands. It measures price deviation from recent highs or lows to detect extreme market conditions and

Strategy v4 Volatility & bandsMean reversion
Updated 3 years ago · Apache-2.0 GitHub repository of Fear + Greed Reversal Short 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