Strategy · Pine Script v5 · On the chart

Omar Edited WF

by Alorse· code credited to B_L_A_C_K_S_C_O_R_P_I_O_N

Omar Edited WF is a trading strategy overlay built around Williams Fractals and multiple Exponential Moving Averages.

View on GitHub

GitHub stars330on the repository
Pine versionv5runs as is
Lines of code167
Settings14inputs
LicenceNone statedfile: MPL-2.0
Last update2 months ago25 Aug 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

167 lines of Pine Script v5 from strategies/other/Omar Edited WF.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Omar Edited WF.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © B_L_A_C_K_S_C_O_R_P_I_O_N
// v 1.1

//@version=5
strategy('Omar Edited WF', overlay=true, pyramiding=0, currency=currency.USD, default_qty_type=strategy.percent_of_equity, initial_capital=1000, default_qty_value=20, commission_type=strategy.commission.percent, commission_value=0.01)

// *************Appearance*************
theme = input.string(defval='dark', options=['light', 'dark'], group='Appearance')
show_fractals = input.bool(false, 'Show Fractals', group='Appearance')
show_ema = input.bool(false, 'Show EMAs', group='Appearance')

// *************colors*************
color_green = color.green
color_red = color.red
color_yellow = color.yellow
color_orange = color.orange
color_blue = color.blue
color_white = color.white

// *************WF*************
// Define "n" as the number of periods and keep a minimum value of 2 for error handling.
n = input.int(title='Fractal Periods', defval=2, minval=2, group='Williams Fractals')

// UpFractal
bool upflagDownFrontier = true
bool upflagUpFrontier0 = true
bool upflagUpFrontier1 = true
bool upflagUpFrontier2 = true
bool upflagUpFrontier3 = true
bool upflagUpFrontier4 = true

for i = 1 to n by 1
    upflagDownFrontier := upflagDownFrontier and high[n - i] < high[n]
    upflagUpFrontier0 := upflagUpFrontier0 and high[n + i] < high[n]
    upflagUpFrontier1 := upflagUpFrontier1 and high[n + 1] <= high[n] and high[n + i + 1] < high[n]
    upflagUpFrontier2 := upflagUpFrontier2 and high[n + 1] <= high[n] and high[n + 2] <= high[n] and high[n + i + 2] < high[n]
    upflagUpFrontier3 := upflagUpFrontier3 and high[n + 1] <= high[n] and high[n + 2] <= high[n] and high[n + 3] <= high[n] and high[n + i + 3] < high[n]
    upflagUpFrontier4 := upflagUpFrontier4 and high[n + 1] <= high[n] and high[n + 2] <= high[n] and high[n + 3] <= high[n] and high[n + 4] <= high[n] and high[n + i + 4] < high[n]
    upflagUpFrontier4
flagUpFrontier = upflagUpFrontier0 or upflagUpFrontier1 or upflagUpFrontier2 or upflagUpFrontier3 or upflagUpFrontier4

upFractal = upflagDownFrontier and flagUpFrontier

// downFractal
bool downflagDownFrontier = true
bool downflagUpFrontier0 = true
bool downflagUpFrontier1 = true
bool downflagUpFrontier2 = true
bool downflagUpFrontier3 = true
bool downflagUpFrontier4 = true

for i = 1 to n by 1
    downflagDownFrontier := downflagDownFrontier and low[n - i] > low[n]
    downflagUpFrontier0 := downflagUpFrontier0 and low[n + i] > low[n]
    downflagUpFrontier1 := downflagUpFrontier1 and low[n + 1] >= low[n] and low[n + i + 1] > low[n]
    downflagUpFrontier2 := downflagUpFrontier2 and low[n + 1] >= low[n] and low[n + 2] >= low[n] and low[n + i + 2] > low[n]
    downflagUpFrontier3 := downflagUpFrontier3 and low[n + 1] >= low[n] and low[n + 2] >= low[n] and low[n + 3] >= low[n] and low[n + i + 3] > low[n]
    downflagUpFrontier4 := downflagUpFrontier4 and low[n + 1] >= low[n] and low[n + 2] >= low[n] and low[n + 3] >= low[n] and low[n + 4] >= low[n] and low[n + i + 4] > low[n]
    downflagUpFrontier4
flagDownFrontier = downflagUpFrontier0 or downflagUpFrontier1 or downflagUpFrontier2 or downflagUpFrontier3 or downflagUpFrontier4

downFractal = downflagDownFrontier and flagDownFrontier

// plotshape(downFractal and show_fractals, style=shape.triangleup, location=location.belowbar, offset=-n, color=color_green)
// plotshape(upFractal and show_fractals, style=shape.triangledown, location=location.abovebar, offset=-n, color=color_red)

// *************EMA*************
len_a = input.int(20, minval=1, title='EMA A   Length', group='Moving Averages', inline="a")
src_a = input.source(close, title='Source', group='Moving Averages', inline="a")
out_a = ta.ema(src_a, len_a)
plot(show_ema ? out_a : na, title='EMA A', color=color_green)

len_b = input.int(50, minval=1, title='EMA B   Length', group='Moving Averages', inline="b")
src_b = input.source(close, title='Source', group='Moving Averages', inline="b")
out_b = ta.ema(src_b, len_b)
ema_b_color = theme == 'dark' ? color_yellow : color_orange
plot(show_ema ? out_b : na, title='EMA B', color=ema_b_color)

len_c = input.int(100, minval=1, title='EMA C   Length', group='Moving Averages', inline="c")
src_c = input.source(close, title='Source', group='Moving Averages', inline="c")
out_c = ta.ema(src_c, len_c)
ema_c_color = theme == 'dark' ? color_white : color_blue
plot(show_ema ? out_c : na, title='EMA C', color=ema_c_color)



// *************RSI*************

len = input.int(14, minval=1, title='Length', group='RSI', inline='rsi')
src = input.source(close, 'Source', group='RSI', inline='rsi', tooltip='3m chart => RSI in 5m\n5m chart => RSI in 15m\n15m chart => RSI in 45m\n1H chart => RSI in 4H\n4H chart => RSI in 1D\n>1D chart => RSI Auto')
RSIFunc(len, src) =>
    up = ta.rma(math.max(ta.change(src), 0), len)
    down = ta.rma(-math.min(ta.change(src), 0), len)
    RSI = ta.rsi(src, len)

    RSI

// Timeframe
timeframeSetUp(number) =>
    switch number
        '3' => '5'
        '5' => '15'
        '15' => '45'
        '60' => '240'
        '240' => 'D'
        => 'Auto'

NormalRsi = RSIFunc(len, src)

defRes = timeframeSetUp(timeframe.period)
rsi = request.security(syminfo.tickerid, defRes, NormalRsi)

// *************Calculation*************
long = out_a > out_b and out_a > out_c and downFractal and low[2] > out_c and rsi[2] < rsi
// short = (out_a < out_b) and (out_a < out_c) and upFractal and high[2] < out_c and rsi[2] > rsi

// plotshape(long, style=shape.labelup, color=color_green, location=location.belowbar, title='long label', text='L', textcolor=color_white)
// plotshape(short, style=shape.labeldown, color=color_red, location=location.abovebar, title="short label", text= "S", textcolor=color_white)

// *************End of Signals calculation*************

// Make inputs that set the take profit % (optional)
longProfitPerc = input.float(title='Long Take Profit (%)', minval=0.0, step=0.1, defval=1.5, group='Orders') * 0.01

// shortProfitPerc = input(title="Short Take Profit (%)",
    //  type=input.float, minval=0.0, step=0.1, defval=0.5, group="Orders") * 0.01

// Figure out take profit price
longExitPrice = strategy.position_avg_price * (1 + longProfitPerc)
// shortExitPrice = strategy.position_avg_price * (1 - shortProfitPerc)

// Plot take profit values for confirmation
// plot(series=strategy.position_size > 0 ? longExitPrice : na, color=color_green, style=plot.style_circles, linewidth=1, title='Long Take Profit')
// plot(series=(strategy.position_size < 0) ? shortExitPrice : na,
    //  color=color_green, style=plot.style_circles,
    //   linewidth=1, title="Short Take Profit")

// Submit entry orders
if long and strategy.opentrades == 0
    strategy.entry(id='🟢', direction=strategy.long)

// if (short and strategy.opentrades == 0)
    // strategy.entry(id="Short", long=false)

// Set stop loss level with input options (optional)
longLossPerc = input.float(title='Long Stop Loss (%)', minval=0.0, step=0.1, defval=3.1, group='Orders') * 0.01

// shortLossPerc = input(title="Short Stop Loss (%)",
    //  type=input.float, minval=0.0, step=0.1, defval=3.1, group="Orders") * 0.01

// Determine stop loss price
longStopPrice = strategy.position_avg_price * (1 - longLossPerc)
// shortStopPrice = strategy.position_avg_price * (1 + shortLossPerc)

// Plot stop loss values for confirmation
// plot(series=strategy.position_size > 0 ? longStopPrice : na, color=color_red, style=plot.style_cross, linewidth=1, title='Long Stop Loss')
// plot(series=(strategy.position_size < 0) ? shortStopPrice : na,
    //  color=color_red, style=plot.style_cross,
    //  linewidth=1, title="Short Stop Loss")

// Submit exit orders based on calculated stop loss price
if strategy.position_size > 0
    strategy.exit(id='🔴', limit=longExitPrice, stop=longStopPrice)

// if (strategy.position_size < 0)
// strategy.exit(id="ExS", limit=shortExitPrice, stop=shortStopPrice)

Overview

Omar Edited WF detects high and low fractal pivot points over configurable lookback periods alongside three adjustable EMA trendlines. Long entries are managed using built-in percentage-based take profit and stop loss controls. Input options allow toggling chart visibility for EMAs and fractal indicators, as well as selecting visual color themes.

Details

Published by

Alorse on GitHub

Code credit

B_L_A_C_K_S_C_O_R_P_I_O_N, as written in the script's header

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Trend, Moving averages, Support & resistance

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

pinescriptpinescript-indicatorspinescript-strategiestrading-strategiestradingviewtradingview-alerttradingview-strategy

Settings

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

SettingTypeDefaultVariable
themestringdarktheme
Show Fractalsboolfalseshow_fractals
Show EMAsboolfalseshow_ema
Fractal Periodsint2n
EMA A   Lengthint20len_a
Sourcesourceclosesrc_a
EMA B   Lengthint50len_b
Sourcesourceclosesrc_b
EMA C   Lengthint100len_c
Sourcesourceclosesrc_c
Lengthint14len
Sourcesourceclosesrc
Show all 14 settings
SettingTypeDefaultVariable
Long Take Profit (%)float1.5longProfitPerc
Long Stop Loss (%)float3.1longLossPerc
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

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

This strategy overlays the price chart and looks for VWAP pullbacks. It goes long when a short SMA crosses above VWAP after RSI has been oversold within ten bars, and short on the opposite cross after RSI has been overbought. Optional Minervini-style moving-av

Strategy v5 TrendOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of Advanced VWAP-Momentum Pullback Trend Qualifier
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

This strategy executes trades based on pivot levels, an exponential moving average, and a multi-stage smoothing trend line. It identifies support and resistance points from pivot highs and lows, combining them with price relationship rules against a custom smo

Strategy v5 TrendMoving averages Repaints
Updated 2 years ago · None stated GitHub repository of Binancash - Candle Strategy Futures on Binance
13 stars

This strategy generates entry signals using pivot points and uses custom Curie moving average closing lines for exiting positions. It features risk management components including percentage-based stop loss, take profit, trailing stops, and break-even levels,

Strategy v5 TrendMoving averages
Updated 1 year ago · None stated GitHub repository of BitLa PivotPoints A002
9 stars

Smooth Trend Radar Strategy calculates a double-smoothed Supertrend baseline using WMA and EMA to identify trend direction and sideway regimes. It plots baseline rejection signals on flips, trend slope filters, and statistical overextension highlights with can

Strategy v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of Smooth Trend Radar 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