Strategy · Pine Script v6 · On the chart

Drawing Line Level Breakout

by pineforge-4pass

A test strategy that draws a red horizontal line which follows a 20-period moving average by moving about a third of the distance each bar, and extends to the right.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code19
Settings0inputs
LicenceApache-2.0
Last update6 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

19 lines of Pine Script v6 from validation/drawing-line-level-breakout/strategy.pine, published under Apache-2.0. Keep the author's credit and licence lines when you reuse it.

strategy.pine
//@version=6
strategy("drawing-line-level-breakout", overlay=true, pyramiding=0, default_qty_type=strategy.fixed, default_qty_value=1)
levelSrc = ta.sma(close, 20)
var line res = na
float level = na
if not na(levelSrc)
    if na(res)
        res := line.new(bar_index - 1, levelSrc, bar_index, levelSrc, color=color.red, width=2, extend=extend.right)
    else
        cur = line.get_y2(res)
        line.set_xy2(res, bar_index, cur + (levelSrc - cur) * 0.35)
    level := line.get_y2(res)
ready = not na(level)
eUp = ready and ta.crossover(close, level)
eDn = ready and ta.crossunder(close, level)
if ready and eUp
    strategy.entry("L", strategy.long)
if strategy.position_size > 0 and ready and eDn
    strategy.close("L")

Overview

Drawing Line Level Breakout goes long when the close crosses above that smoothed line and closes the long when the close crosses below. It takes one unit at a time with no stop loss or take profit. Its main purpose is to exercise line drawing functions in a reference corpus, so it is a code example rather than a tuned system.

Details

Published by

pineforge-4pass on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Moving averages, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

algorithmic-tradingbacktestingparitypine-scriptpinescriptquantitative-financetest-corpustradingview

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
106 stars

This strategy plots on the price chart and enters when three smoothed moving averages are aligned, RSI is on the matching side of 50, and a Williams fractal appears. An upward stack with RSI above 50 and a down fractal opens a long; the opposite setup opens a

Strategy v5 Moving averagesOscillators & momentum
Updated 2 years ago · GPL-3.0 GitHub repository of 3SmmaCrossUp + Fractal + RSI
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

KC15

by benso87
24 stars

KC15 is a price-chart strategy that configures two moving averages, a Bollinger Band Width Percentile filter, and PMARP entry and exit thresholds for long and short trades. Users can switch each average between SMA and EMA, set lengths and colors, and toggle l

Strategy v5 Moving averagesVolatility & bands
Updated 4 years ago · MPL-2.0 GitHub repository of KC15

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