//@version=6
strategy("While Loop Counter", overlay=true)
len = input.int(4, "Len")
f_sum_last(_len) =>
total = 0.0
idx = 0
while idx < _len
total += nz(close[idx], 0)
idx += 1
total
score = f_sum_last(len)
avg = score / len
longCondition = close > avg
shortCondition = close < avg
if longCondition
strategy.entry("Long", strategy.long)
else if shortCondition
strategy.entry("Short", strategy.short)
else
strategy.close("Long")
strategy.close("Short")
Overview
While Loop Counter enters long when close exceeds the average and short when below. Positions close automatically on reversal. No stop loss is applied and entries occur on every bar.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
Len
int
4
len
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.
Mean Reversion Strategy is an overlay strategy that identifies pullbacks using a long-term EMA, RSI, and candlestick patterns. It generates long signals when a bullish engulfing candle forms below the EMA while RSI is oversold, and short signals when a bearish
This strategy combines a 7-period RSI with an ADX filter to trade market regimes on the price chart. When the ADX indicates ranging conditions below a set threshold, it triggers entries on RSI overbought or oversold extremes. By default, the entry logic is inv
This strategy combines a Simple Moving Average (SMA) and the Relative Strength Index (RSI) to generate long trading signals. It enters a long position when price closes above the SMA filter while RSI drops below the oversold threshold. The strategy exits the p
This strategy enters long when a series labeled ADX is above a threshold and RSI is below 40, and enters short when that series is above the threshold and RSI is above 60. Both series are calculated with the RSI function, so the trend filter is not a true ADX.
This strategy trades pullbacks in the direction of a moving-average trend and draws on the price chart. An uptrend requires the 50-period EMA above the 200-period EMA with price above the slower average, and a downtrend is the reverse. It enters long or short
Lucid 100K v5 is a Pine Script strategy for trading MES futures on 5-minute charts. It overlays buy and sell signals directly on the price chart. The strategy runs two phases based on equity and recent profit factor. Phase 1 uses trend pullback entries with EM