Strategy · Pine Script v5 · Own pane

My Custom Strategy 1

by might-tree

This long-only strategy plots a 20-period exponential moving average of the low, a 20-period simple moving average of the low, and the close in a separate pane.

View on GitHub

Repaints

GitHub stars4on the repository
Pine versionv5runs as is
Lines of code26
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update3 years ago2 Aug 2023

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

26 lines of Pine Script v5 from Custom_Strategies/My_Strategy_1.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

My_Strategy_1.pine
//Run the following Script on PINE EDITOR or any platform supporting Pine Script

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © might-tree

//@version=5
strategy("My Custom Strategy 1", overlay=false, margin_long=100, margin_short=100)
import TradingView/ta/5

my_ema=ta.ema(low,20)
my_sma=ta.sma(low,20)
my_swma=ta.swma(close)

highestHigh = ta.highest(close, 25)[1]
lowestLow   = ta.lowest(close, 25)[1]
randomPoint    = (highestHigh + lowestLow)/5

if high > highestHigh and close>my_ema-5 and close>my_sma
    strategy.entry("Enter Long", strategy.long)

if ta.crossunder(low, close)
    strategy.close("Enter Long", comment="Exit Long")

plot(my_ema, color=color.green)
plot(my_sma, color=color.red)
plot(close, color=color.blue)

Overview

My Custom Strategy 1 enters long when the high breaks the prior 25-bar highest close and the close is above both the simple moving average and the exponential moving average minus five. It closes the long when the low crosses under the close. There is no stop loss, take profit, or position sizing. A 25-bar lowest close and a weighted moving average are calculated but unused. Signals can change before the bar closes.

Details

Published by

might-tree on GitHub

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)
  • The strategy enters trades without a stop loss
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

Combo

by pouyA-png
1 stars

This strategy executes opening range breakout trades during regular trading hours. It calculates a 15-minute opening range high and low alongside a 20-period EMA and a 14-period ATR. Long entries trigger when price crosses above the opening range high while hi

Strategy v5 BreakoutSessions & time
Updated 2 weeks ago · None stated GitHub repository of Combo
257 stars

This strategy plots running pivot highs as red R circles and pivot lows as blue S circles directly on the price chart. It computes an EMA 3 and a Cto trend line from close prices, then generates long signals on upward EMA-Cto crossovers combined with price pos

Strategy v6 TrendMoving averages Repaints
Updated 7 weeks ago · None stated GitHub repository of Best Chart 1m Strategy Candle Bar

Bollinger Breakout

by hackingthemarkets
189 stars

This price-chart strategy plots a simple moving average and upper and lower bands built from the standard deviation of close, scaled by separate offset inputs. It enters a fixed quantity long when close crosses above the upper band and a fixed quantity short w

Strategy v4 Volatility & bandsBreakout
Updated 3 years ago · None stated GitHub repository of Bollinger Breakout

12/26-IT Strategy

by hasnocool
106 stars

This strategy executes trades based on crossovers between a 12-period and a 26-period exponential moving average (EMA). Long positions can be filtered by pivot resistance breakouts and RSI boundary ranges. For trade management, it provides two configurable par

Strategy v5 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 12/26-IT Strategy

均线突破交易系统

by tangly1024
76 stars

This strategy trades long breakouts of a fast and a slow moving average on the price chart. It opens a long position when price crosses above either average, using a percentage of equity as size. It reduces the position by a set share when the high reaches the

Strategy v5 TrendMoving averages
Updated 5 months ago · None stated GitHub repository of 均线突破交易系统

More Moving averages scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers