Strategy · Pine Script v6 · On the chart

PineForge Quarry ALMA Correlation

by pineforge-4pass· code credited to PineForge

This strategy calculates an ALMA smoothed version of the close price and the correlation between close and volume.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code36
Settings7inputs
LicenceApache-2.0
Last update5 days ago23 Oct 2026

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

36 lines of Pine Script v6 from validation/ta-quarry-alma-correlation-01/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
//@version=6
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 PineForge
// PineForge Owned Strategy: Quarry ALMA Correlation
// A smoothed price transition is admitted only when price and volume co-move.
strategy("PineForge — Quarry ALMA Correlation", overlay=true,
     initial_capital=100000,
     default_qty_type=strategy.fixed, default_qty_value=2,
     pyramiding=0, commission_type=strategy.commission.percent,
     commission_value=0.05, slippage=1,
     margin_long=100, margin_short=100,
     process_orders_on_close=false, calc_on_order_fills=false)

almaLength = input.int(31, "ALMA Length", minval=5, group="Signal")
almaOffset = input.float(0.72, "ALMA Offset", minval=0.05, maxval=0.95, step=0.01, group="Signal")
almaSigma = input.float(5.4, "ALMA Sigma", minval=1.0, maxval=12.0, step=0.1, group="Signal")
correlationLength = input.int(23, "Correlation Length", minval=5, group="Confirmation")
minimumCorrelation = input.float(0.04, "Minimum Correlation", minval=-0.8, maxval=0.8, step=0.01, group="Confirmation")
atrLength = input.int(17, "ATR Length", minval=2, group="Risk")
maximumAtrLoss = input.float(2.6, "Maximum ATR Loss", minval=0.5, step=0.1, group="Risk")

almaLine = ta.alma(close, almaLength, almaOffset, almaSigma)
priceVolumeCorrelation = ta.correlation(close, volume, correlationLength)
atrValue = ta.atr(atrLength)

enterLong = ta.crossover(close, almaLine) and priceVolumeCorrelation > minimumCorrelation
regimeEnded = ta.crossunder(close, almaLine) or priceVolumeCorrelation < -minimumCorrelation
riskExceeded = strategy.position_size > 0 and close < strategy.position_avg_price - atrValue * maximumAtrLoss

if strategy.position_size == 0 and enterLong
    strategy.entry("Quarry Long", strategy.long)
else if strategy.position_size > 0 and (regimeEnded or riskExceeded)
    strategy.close("Quarry Long", comment=riskExceeded ? "ATR risk" : "Correlation regime")

plot(almaLine, "ALMA Center", color=color.orange)
plot(priceVolumeCorrelation, "Price-Volume Correlation", color=color.teal, display=display.data_window)

Overview

PineForge Quarry ALMA Correlation enters long trades when price crosses above ALMA and correlation exceeds the minimum threshold. It exits on price crossing below ALMA, correlation falling below the negative minimum, or when price drops below average entry by ATR times maximum ATR loss. The main settings control ALMA length offset and sigma, correlation length and minimum, ATR length, and maximum ATR loss. It draws the ALMA line on the price chart and correlation in the data window. It uses fixed size with no pyramiding.

Details

Published by

pineforge-4pass on GitHub

Code credit

PineForge, as written in the script's header

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Moving averages, Volatility & bands, Volume, Trend

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

Settings

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

SettingTypeDefaultVariable
ALMA Lengthint31almaLength
ALMA Offsetfloat0.72almaOffset
ALMA Sigmafloat5.4almaSigma
Correlation Lengthint23correlationLength
Minimum Correlationfloat0.04minimumCorrelation
ATR Lengthint17atrLength
Maximum ATR Lossfloat2.6maximumAtrLoss
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

Prototype

by hasnocool
106 stars

This strategy overlays Supertrend-style ATR trailing stop levels on the price chart alongside multi-period moving averages, volume metrics, and Bollinger Bands. It flags trend direction changes using an ATR offset channel, plotting buy and sell signals directl

Strategy v4 TrendVolatility & bands
Updated 2 years ago · GPL-3.0 GitHub repository of Prototype

This strategy enters long or short when eight conditions align over the last two bars. It requires EMA 10 and EMA 55 alignment on the one-hour, four-hour and daily charts, a positive ADX slope, matching monitor direction, and price relative to a 400-bar point

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of Ruckard ABCBitcoin TradingLatino B002
8 stars

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

Strategy v5 TrendVolatility & bands
Updated 4 years ago · None stated GitHub repository of ATR 3Lvls VP Strategy
4 stars

This trend-following strategy generates long and short entries when a fast EMA crosses a slow EMA, overlaying directly on the price chart. To reduce false signals, it applies four configurable fakeout filters: volume moving average threshold, consecutive bar c

Strategy v6 TrendMoving averages
Updated 2 months ago · MIT GitHub repository of Fakeout-Confirmed Strategy
2 stars

This overlay strategy enters long when a fast EMA crosses above a slow EMA, the candle closes above the fast EMA and above its open, and volume is at least a set multiple of its SMA. Position size defaults to 95 percent of equity with no pyramiding. It exits w

Strategy v5 TrendMoving averages
Updated 8 weeks ago · None stated GitHub repository of EMA20/50 ATR Trail Spot

My First Indicator

by wynnforthework
2 stars

This strategy plots EMA 25 in yellow and EMA 100 in green on the price chart. It generates buy signals on EMA 25 crossing above EMA 100 when ATR length 14 rises over two prior bars and volume exceeds prior bar. It opens a long position of 1 unit on signal. It

Strategy v5 Moving averagesTrend
Updated 1 year ago · None stated GitHub repository of My First Indicator

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