//@version=6
// Copyright (c) 2021-present, Alex Orekhov (everget)
// Nick Rypock Trailing Reverse (NRTR) script may be freely distributed under the terms of the GPL-3.0 license.
indicator('Nick Rypock Trailing Reverse', shorttitle = 'NRTR', overlay = true)
const string calcGroup = 'Calculation'
percentage = input.float(2, minval = 0, maxval = 100, step = 0.1, title = 'Coefficient of Correction, %', group = calcGroup) / 100
const string visualGroup = 'Visuals'
showLabels = input.bool(true, title = 'Show Buy/Sell Labels', group = visualGroup)
highlightState = input.bool(true, title = 'Highlight State', group = visualGroup)
//---
var int trend = 0
var float hp = close
var float lp = close
nrtr = close
if trend >= 0
if close > hp
hp := close
hp
nrtr := hp * (1 - percentage)
if close <= nrtr
trend := -1
lp := close
nrtr := lp * (1 + percentage)
nrtr
else
if close < lp
lp := close
lp
nrtr := lp * (1 + percentage)
if close > nrtr
trend := 1
hp := close
nrtr := hp * (1 - percentage)
nrtr
const color textColor = color.white
const color longColor = color.green
const color shortColor = color.red
const color longFillColor = color.new(color.green, 85)
const color shortFillColor = color.new(color.red, 85)
longStopPlot = plot(trend == 1 ? nrtr : na, title = 'Long Stop', style = plot.style_linebr, linewidth = 2, color = longColor)
buySignal = trend == 1 and trend[1] == -1
plotshape(buySignal ? nrtr : na, title = 'Long Stop Start', location = location.absolute, style = shape.circle, size = size.tiny, color = longColor)
plotshape(buySignal and showLabels ? nrtr : na, title = 'Buy Label', text = 'Buy', location = location.absolute, style = shape.labelup, size = size.tiny, color = longColor, textcolor = textColor)
shortStopPlot = plot(trend == 1 ? na : nrtr, title = 'Short Stop', style = plot.style_linebr, linewidth = 2, color = shortColor)
sellSignal = trend == -1 and trend[1] == 1
plotshape(sellSignal ? nrtr : na, title = 'Short Stop Start', location = location.absolute, style = shape.circle, size = size.tiny, color = shortColor)
plotshape(sellSignal and showLabels ? nrtr : na, title = 'Sell Label', text = 'Sell', location = location.absolute, style = shape.labeldown, size = size.tiny, color = shortColor, textcolor = textColor)
midPricePlot = plot(ohlc4, title = '', display = display.none, editable = false)
fill(midPricePlot, longStopPlot, title = 'Long State Filling', color = (highlightState and trend == 1 ? longFillColor : na))
fill(midPricePlot, shortStopPlot, title = 'Short State Filling', color = (highlightState and trend == -1 ? shortFillColor : na))
alertcondition(trend != trend[1], title = 'NRTR Direction Change', message = 'NRTR has changed direction, {{exchange}}:{{ticker}}')
alertcondition(buySignal, title = 'NRTR Buy', message = 'NRTR Buy, {{exchange}}:{{ticker}}')
alertcondition(sellSignal, title = 'NRTR Sell', message = 'NRTR Sell, {{exchange}}:{{ticker}}')
Overview
In an uptrend it trails below the highest close by the correction coefficient; in a downtrend it trails above the lowest close. A direction change marks a buy or sell, with optional labels and circles at the new stop. The coefficient sets the trail distance, and optional fills highlight the long or short state. Alerts fire on direction changes and on buy or sell signals. It is an indicator with no position sizing or exit rules.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Coefficient of Correction, %
float
2
percentage
Show Buy/Sell Labels
bool
true
showLabels
Highlight State
bool
true
highlightState
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.
This indicator detects equal highs and lows by comparing prices within user-defined left and right bars using a tolerance percentage. It plots horizontal lines on the price chart for equal highs in one color and lows in another. A screener allows input of mult
This indicator classifies each bar as bull, bear, or sideways from a rolling log return compared with adjustable percentage thresholds. It paints a regime ribbon on the price chart, shows a current-regime banner, and labels state changes after a minimum hold.
This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab
This indicator calculates an ATR trailing stop line derived from the highest high minus an average true range multiple over a specified lookback period. It plots the trailing stop line directly on the price chart and colors price bars based on whether the clos
All Candlestick Patterns detects and highlights a wide range of bullish, bearish, and neutral candlestick patterns directly on the price chart. It features optional trend filtering using either a 50-period simple moving average or a combination of 50-period an
This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre