Strategy · Pine Script v5 · On the chart

Optimized Volume + Fibonacci + Trend + ATR Strategy

by 11Muhil

This strategy combines volume surge detection, Fibonacci retracements, moving averages, and ATR volatility for trade execution.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code57
Settings10inputs
LicenceMIT
Last update1 year ago11 Feb 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

57 lines of Pine Script v5 from Scripts/FibTrend_ATR.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

FibTrend_ATR.pine
//@version=5
// DISCLAIMER: This script is for educational purposes only.  
// Use it at your own risk. No guarantee of profitability.  

strategy("Optimized Volume + Fibonacci + Trend + ATR Strategy", overlay=true)

// Input settings
length = input(24, title="Volume Lookback Period")
fibLevel1 = input(0.618, title="Fibonacci Level 1")
fibLevel2 = input(0.5, title="Fibonacci Level 2")
riskReward = input(3.0, title="Risk to Reward Ratio")  // Increased R:R for maximizing profits
smaLength = input(200, title="SMA Length for Trend Filter")  
atrLength = input(14, title="ATR Length")  
trailPerc = input(1.5, title="Trailing Stop %") / 100  // Trailing stop for maximizing profit
emaShort = input(9, title="Short EMA")  
emaLong = input(26, title="Long EMA")  
lookbackPeriod = input(50, title="Fibonacci Lookback Period")

// Volume Calculation
volume24 = ta.sma(volume, length)
volumeCondition = volume > volume24

// Fibonacci Calculation
var float highLevel = na
var float lowLevel = na
if (bar_index >= lookbackPeriod)
    highLevel := ta.highest(high, lookbackPeriod)
    lowLevel := ta.lowest(low, lookbackPeriod)

fib618 = lowLevel + (highLevel - lowLevel) * fibLevel1
fib50 = lowLevel + (highLevel - lowLevel) * fibLevel2

plot(fib618, color=color.red, title="Fib 0.618")
plot(fib50, color=color.blue, title="Fib 0.5")

// Trend Confirmation
sma200 = ta.sma(close, smaLength)
emaFast = ta.ema(close, emaShort)
emaSlow = ta.ema(close, emaLong)

// ATR-based Stop Loss & Take Profit
atr = ta.atr(atrLength)
stopLoss = close - atr * 1.5  // Stop loss at 1.5x ATR
takeProfitATR = close + atr * riskReward  // Dynamic TP

// Buy Condition: Price > Fibonacci 0.618 + EMA Cross + Above SMA200 + Volume Surge
buyCondition = close > fib618 and emaFast > emaSlow and close > sma200 and volumeCondition
if (buyCondition)
    strategy.entry("Buy", strategy.long)

// Sell Condition: Price < Fibonacci 0.5 + Volume Surge (Exit Condition)
sellCondition = close < fib50 and volumeCondition
if (sellCondition)
    strategy.close("Buy")

// Exit Conditions (Maximized Profits)
strategy.exit("Take Profit ATR", from_entry="Buy", limit=takeProfitATR, stop=stopLoss, trail_price=close, trail_offset=close * trailPerc)

Overview

Long positions trigger when price exceeds the 0.618 Fibonacci level, price stays above a 200-period SMA, a fast EMA crosses above a slow EMA, and volume exceeds its moving average. The position exits if price falls below the 0.5 Fibonacci level on high volume, or hits ATR-based stop loss and take profit targets with trailing stop offsets. User settings control Fibonacci lookback periods, EMA lengths, and ATR risk-reward multipliers. It overlay plots directly on the price chart.

Details

Published by

11Muhil on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, Volume, Support & resistance

Markets

Forex, Crypto, Stocks

Timeframes

M15-H1, H4 and above

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
Volume Lookback Periodint24length
Fibonacci Level 1float0.618fibLevel1
Fibonacci Level 2float0.5fibLevel2
Risk to Reward Ratiofloat3.0riskReward
SMA Length for Trend Filterint200smaLength
ATR Lengthint14atrLength
Trailing Stop %float1.5trailPerc
Short EMAint9emaShort
Long EMAint26emaLong
Fibonacci Lookback Periodint50lookbackPeriod
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

Omar Edited WF

by Alorse
330 stars

Omar Edited WF is a trading strategy overlay built around Williams Fractals and multiple Exponential Moving Averages. It detects high and low fractal pivot points over configurable lookback periods alongside three adjustable EMA trendlines. Long entries are ma

Strategy v5 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of Omar Edited WF
257 stars

This strategy calculates dynamic support and resistance levels using pivot highs and lows alongside a custom smoothed trend filter and a 3-period EMA. It identifies entry opportunities when price breaks out relative to the trend filter and short-term EMA cross

Strategy v5 TrendSupport & resistance Repaints
Updated 6 weeks ago · None stated GitHub repository of 30s - ES 1m Strategy Candle Bar
218 stars

This strategy enters long when a faster moving average crosses above a slower one and short when it crosses below, unless long-only mode is on. An optional volume filter requires volume above a 20-bar average times a multiplier. Exits use a percentage stop los

Strategy v6 TrendMoving averages
Updated 3 months ago · None stated GitHub repository of MA Cross Strategy Template

4x EMA + Volume

by hasnocool
106 stars

This strategy plots four exponential moving averages on the price chart and filters trades with a smoothed Ease of Movement oscillator. In the default mode it opens a long when price and the four averages are stacked upward and Ease of Movement is positive, th

Strategy v4 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 4x EMA + Volume
104 stars

This strategy combines three Exponential Moving Averages with Williams Fractals to execute trend-following or mean-reverting trades. It analyzes price structure using short, medium, and long-term EMAs along with fractal highs and lows. Entries trigger when fra

Strategy v5 TrendMoving averages
Updated 3 years ago · MIT GitHub repository of 3MA and Fractals 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