Strategy · Pine Script v5 · On the chart

NakInvest Cross EMA With RSI Divergence

by feliperazeek

This strategy looks for three-candle patterns, namely the 123 pattern, PFR and engulfing candles, filtered by a trend of stacked EMAs, and adds an optional RSI divergence filter drawn as lines on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv5runs as is
Lines of code222
Settings38inputs
LicenceNone stated
Last update1 year ago11 Oct 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above. It reads the file straight from GitHub.
  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

The code stays on GitHub. The author has not published this script under an open licence, so ForexR does not show its code. Copy script reads the file straight from GitHub into your clipboard, so you can still try it on your own chart. Ask the author before reusing the code anywhere else.

Overview

Further optional filters use volume and a stochastic. Candle size rules are adjustable. Stop loss can sit below the candle body or wick, at a percentage or at a recent low, with take profit set by a risk-reward ratio or a percentage. It sizes positions by percent of equity.

Details

Published by

feliperazeek on GitHub

Draws

On the price chart

Markets

Crypto

Timeframes

M15-H1

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
Use RSI Divergence FilterboolfalseuseRsiDivFilter
RSI Lengthint14rsiLength
RSI Divergence Lookbackint20rsiDivLookback
Bullish Divergence Colorcolorcolor.greenbulldivcol
Bearish Divergence Colorcolorcolor.redbeardivcol
Divergence Line Widthint1divwidth
Min Candle 1 Size (absolute units)float0.1minCandle1Size
Min Candle 2 Body Size as % of Candle 1float0.1minCandle2Pct
Max Candle 2 Body Size as % of Candle 1float0.5maxCandle2Pct
Min Candle 3 Body Size as % of Candle 1float0.6minCandle3Pct
Max Candle 3 Body Size as % of Candle 1float1.5maxCandle3Pct
Enable Long PositionsbooltrueenableLong
Show all 38 settings
SettingTypeDefaultVariable
Enable Short PositionsbooltrueenableShort
Use Trend FilterbooltrueuseTrendFilter
Use Volume FilterboolfalseuseVolumeFilter
Minimum Volume Multiplierfloat1.5minVolume
Use Stochastic FilterboolfalseuseStochFilter
Stochastic Lengthint21stochLength
Stoch Overboughtfloat50stochOverbought
Stoch Oversoldfloat50stochOversold
Take Profit TypestringRR-BasedtpType
Take Profit Ratio (vs SL)float1.0profitTargetRR
Take Profit % From Entryfloat1.0tpPercent
Stop Loss TypestringBelow Candle WickslType
Stop Loss %float1.0slPercent
Number of Candles for Lowest Lowint10slCandlesLookback
Price Comparison Buffer (%)float0.001priceBufferPct
Enable 123 Patternbooltrueenable123
Enable PFR PatternbooltrueenablePFR
Enable Engulfing PatternbooltrueenableEngulfing
Use MACD ConfirmationboolfalseuseMacdConfirmation
MACD Fast Lengthint12macdFastLength
MACD Slow Lengthint26macdSlowLength
MACD Signal Lengthint9macdSignalLength
MA TypestringEMAmaType
Fast MA Lengthint9fastLength
Medium MA Lengthint40mediumLength
Slow MA Lengthint80slowLength
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

330 stars

This strategy enters long when a bullish candle closes above an EMA and its upper wick is no larger than a set percent of the candle range, and short on the opposite bearish setup. It closes a long after price rises a small fixed fraction above the entry bar o

Strategy v5 Candlestick patternsMoving averages
Updated 2 months ago · None stated GitHub repository of Full Candle [Alorse]
257 stars

This overlay strategy marks short-term turning points on the price chart and enters SPY option-style trades from them. It plots simple moving averages of highs and lows, draws up and down reversal arrows, and colors bars when a short-term extreme coincides wit

Strategy v5 TrendMoving averages Repaints
Updated 6 weeks ago · None stated GitHub repository of SPY Options Trading - Alert

This strategy calculates and plots smoothed Heikin-Ashi candles directly onto the main price chart using exponential moving averages of open, high, low, and close prices. It enters a long position after three consecutive bullish smoothed candles with sequentia

Strategy v4 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of Abdoli's Heikin Ashi Smoothed Buy & Sell Strategy Rev.4
24 stars

This overlay strategy combines a Cipher B WaveTrend oscillator with two optional moving averages on the price chart. It exposes WaveTrend channel and average lengths, overbought and oversold levels, buy, sell and gold dots, and regular or hidden divergence mar

Strategy v5 Oscillators & momentumMoving averages
Updated 4 years ago · MPL-2.0 GitHub repository of Cipher B + EMAs Strategy

DI Engulfing A002

by ruckard
13 stars

This strategy executes trades based on candlestick engulfing patterns aligned with a 200-period exponential moving average trend filter. It enters long positions when a bullish engulfing candle follows three consecutive bearish candles while price trades above

Strategy v5 Candlestick patternsTrend
Updated 1 year ago · None stated GitHub repository of DI Engulfing A002

More Candlestick patterns 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