Strategy · Pine Script v5 · On the chart

@@rp_Indicator

by hasnocool

This overlay strategy plots exponential moving averages of length 21, 55, 100, and 200 on the price chart.

View on GitHub

GitHub stars106on the repository
Pine versionv5runs as is
Lines of code51
Settings0inputs
LicenceGPL-3.0
Last update2 years ago18 Sep 2024

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

51 lines of Pine Script v5 from @@rp_Indicator.pine, published under GPL-3.0. Keep the author's credit and licence lines when you reuse it.

@@rp_Indicator.pine
//@version=5
strategy(title='@@rp_Indicator', default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_type=strategy.commission.percent, commission_value=.0020, pyramiding=0, slippage=3, overlay=true)
//----------//
// MOMENTUM //
//----------//
ema55 = ta.ema(close, 55)
ema100 = ta.ema(close, 100)
ema200 = ta.ema(close, 200)
ema21 = ta.ema(close, 21)
plot(ema55, color=color.new(color.red, 0), style=plot.style_line, title='55', linewidth=1)
plot(ema100, color=color.new(color.blue, 0), style=plot.style_line, title='100', linewidth=1)
plot(ema200, color=color.new(color.yellow, 0), style=plot.style_line, title='200', linewidth=1)
plot(ema21, color=color.new(color.orange, 0), style=plot.style_line, title='21', linewidth=1)
//plot(ema34, color=color.new(color.red, 0), style=plot.style_line, title='34', linewidth=1)
//longEmaCondition = ema8 > ema13 and ema13 > ema21 and ema21 > ema34 and ema34 > ema55
//exitLongEmaCondition = ema13 < ema55
//shortEmaCondition = ema8 < ema13 and ema13 < ema21 and ema21 < ema34 and ema34 < ema55
//exitShortEmaCondition = ema13 > ema55
// ----------  //
// OSCILLATORS //
// ----------- //
//rsi = rsi(close, 14)
//longRsiCondition = rsi < 70 and rsi > 40
//exitLongRsiCondition = rsi > 70
//shortRsiCondition = rsi > 30 and rsi < 60
//exitShortRsiCondition = rsi < 30
// Stochastic
//length = 14, smoothK = 3, smoothD = 3
//kFast = stoch(close, high, low, 14)
//dSlow = sma(kFast, smoothD)
//longStochasticCondition = kFast < 80
//exitLongStochasticCondition = kFast > 95
//shortStochasticCondition = kFast > 20
//exitShortStochasticCondition = kFast < 5
//----------//
// STRATEGY //
//----------//
//longCondition = longEmaCondition and longRsiCondition and longStochasticCondition and strategy.position_size == 0
//exitLongCondition = (exitLongEmaCondition or exitLongRsiCondition or exitLongStochasticCondition) and strategy.position_size > 0
///if (longCondition)
// strategy.entry("LONG", strategy.long)
//if (exitLongCondition)
//  strategy.close("LONG")
//
//shortCondition = shortEmaCondition and shortRsiCondition and shortStochasticCondition and strategy.position_size == 0
//exitShortCondition = (exitShortEmaCondition or exitShortRsiCondition or exitShortStochasticCondition) and strategy.position_size < 0
//if (shortCondition)
//  strategy.entry("SHORT", strategy.short)
//if (exitShortCondition)
//    strategy.close("SHORT")
Expand (66 lines)

Overview

@@rp_Indicator is declared as a strategy that sizes orders as a percentage of equity and applies a percent commission and slippage, with pyramiding disabled. The momentum, oscillator, long, and short entry and exit conditions in the visible code are commented out, so the script does not place trades or define a stop loss or take profit.

Details

Published by

hasnocool on GitHub

Type

Strategy, Pine Script v5

Draws

On the price chart

Category

Moving averages

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • The strategy enters trades without a stop loss

Topics

analysisbtcusdtcryptocurrencydatapandaspythonsimulationtradingtradingview

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

Doge SMA

by hackingthemarkets
474 stars

Doge SMA is a long-only moving-average crossover strategy drawn on the price chart. It calculates a fast and a slow simple moving average of close and enters a long position when the fast average crosses above the slow average, but only inside a user-defined s

Strategy v4 TrendMoving averages
Updated 4 years ago · None stated GitHub repository of Doge SMA

This strategy calculates and plots a fast Exponential Moving Average (EMA) and a slow EMA directly on the main price chart. It enters long trades when the fast EMA crosses above the slow EMA and exits when the fast EMA crosses below the slow EMA. Inputs allow

Strategy v6 TrendMoving averages
Updated today · AGPL-3.0 GitHub repository of Forven S01508 — Simple EMA20/50 Cross
330 stars

2 EMA/SMA + RSI Strategy [Alorse] combines three configurable moving averages with a short-period Relative Strength Index filter. It plots fast, slow, and trend moving averages on the price chart. Long entries trigger when the fast moving average is above the

Strategy v4 TrendOscillators & momentum
Updated 2 months ago · None stated GitHub repository of 2 EMA/SMA + RSI Strategy [Alorse]

Acrypto - Weighted Strategy

by AlbertoCuadra
318 stars

This strategy plots on the price chart and opens long or short positions when a weighted score from MACD, Stochastic RSI, RSI, Supertrend and a moving-average crossover exceeds a user-set trigger. Each component has its own weight and candle delay. Entries can

Strategy v5 TrendOscillators & momentum
Updated 3 years ago · Custom licence GitHub repository of Acrypto - Weighted Strategy

This overlay strategy offers two selectable entry modes: a Bollinger squeeze on typical price and a simple moving-average cross. It filters trades by weekday, session, date range, and an optional news window, and can restrict direction or invert the side. Risk

Strategy v5 Volatility & bandsMoving averages
Updated today · None stated GitHub repository of Boilerplate Configurable Strategy [Yosiet]
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

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