OPEN-SOURCE SCRIPT
Buy-Dip / Sell-Pullback

Buy the Dip / Sell the Pullback – Trend-Following Strategy (EOD → Next Day Execution)
Overview
This is a trend-following futures strategy designed to participate in pullbacks within established trends, not to predict reversals.
It works on End-of-Day (EOD) confirmation and executes trades on the next trading session, making it suitable for positional and swing traders.
The strategy combines momentum, trend direction, volatility, and price location to filter for high-quality setups while avoiding overtrading.
🔍 Core Philosophy
Trade only in the direction of the prevailing trend
Buy dips in uptrends
Sell pullbacks in downtrends
Avoid chasing price after extended gaps
Use volatility-adjusted risk management (ATR-based SL & targets)
📊 Indicators Used
RSI (20)
Measures underlying momentum strength
Stochastic Oscillator (55, 34, 21)
Confirms pullback exhaustion within a trend
Supertrend (10, 2)
Defines primary trend direction
Bollinger Bands (20, 2)
Provides structural trend bias
ATR (5)
Used for:
Entry gap filter
Stop-loss
Profit target
Supertrend buffer
✅ Long (Buy) Setup – Evaluated at EOD
A long setup is generated when all of the following conditions are satisfied at the close of the trading day:
RSI(20) is above the bullish threshold (default: 48)
Stochastic %K is above %D (confirming pullback momentum)
Supertrend direction is bullish
Price is near or above Supertrend, allowing a volatility-adjusted buffer (ATR-based)
Price is above the Bollinger Band middle line
This combination ensures:
The market is trending up
Momentum supports continuation
The pullback is controlled, not a breakdown
❌ Short (Sell) Setup – Evaluated at EOD
A short setup is generated when:
RSI(20) is below the bearish threshold (default: 52)
Stochastic %K is below %D
Supertrend direction is bearish
Price is near or below Supertrend, with an ATR buffer
Price is below the Bollinger Band middle line
This filters for pullbacks within sustained downtrends.
⏰ Trade Execution Logic (Next Day Rule)
Once a setup is confirmed at EOD, a trade is attempted on the next trading session
To avoid chasing gaps:
Long trades are allowed only if price does not move more than a defined multiple of the previous day’s True Range
Short trades follow the same logic in reverse
This is implemented via limit orders, ensuring realistic backtesting and execution behavior
🛑 Risk Management
All exits are volatility-adjusted using ATR:
Stop-Loss:
1.1 × ATR(5) from entry price
Target:
2.2 × ATR(5) from entry price
This results in a risk–reward ratio of approximately 1:2
ATR is frozen at entry to avoid forward-looking bias.
🧠 Why This Strategy Works
Avoids low-quality trades during consolidation
Participates only when trend + momentum align
Prevents emotional gap-chasing
Adapts automatically to changing volatility
Suitable for index futures and liquid stocks
📌 Recommended Usage
Timeframe: Daily
Instruments:
Index Futures (e.g. NIFTY, BANKNIFTY)
Highly liquid stocks
Market Type: Trending markets
Not ideal for: Sideways or low-volatility environments
⚙️ Customization Tips
You can control trade frequency and aggressiveness by adjusting:
RSI thresholds
Supertrend buffer (ATR multiple)
Gap filter multiplier
Stochastic edge parameter
Looser settings → more trades
Stricter settings → higher selectivity
⚠️ Disclaimer
This strategy is for educational and research purposes only.
Backtest results do not guarantee future performance.
Always validate with paper trading before deploying real capital.
Overview
This is a trend-following futures strategy designed to participate in pullbacks within established trends, not to predict reversals.
It works on End-of-Day (EOD) confirmation and executes trades on the next trading session, making it suitable for positional and swing traders.
The strategy combines momentum, trend direction, volatility, and price location to filter for high-quality setups while avoiding overtrading.
🔍 Core Philosophy
Trade only in the direction of the prevailing trend
Buy dips in uptrends
Sell pullbacks in downtrends
Avoid chasing price after extended gaps
Use volatility-adjusted risk management (ATR-based SL & targets)
📊 Indicators Used
RSI (20)
Measures underlying momentum strength
Stochastic Oscillator (55, 34, 21)
Confirms pullback exhaustion within a trend
Supertrend (10, 2)
Defines primary trend direction
Bollinger Bands (20, 2)
Provides structural trend bias
ATR (5)
Used for:
Entry gap filter
Stop-loss
Profit target
Supertrend buffer
✅ Long (Buy) Setup – Evaluated at EOD
A long setup is generated when all of the following conditions are satisfied at the close of the trading day:
RSI(20) is above the bullish threshold (default: 48)
Stochastic %K is above %D (confirming pullback momentum)
Supertrend direction is bullish
Price is near or above Supertrend, allowing a volatility-adjusted buffer (ATR-based)
Price is above the Bollinger Band middle line
This combination ensures:
The market is trending up
Momentum supports continuation
The pullback is controlled, not a breakdown
❌ Short (Sell) Setup – Evaluated at EOD
A short setup is generated when:
RSI(20) is below the bearish threshold (default: 52)
Stochastic %K is below %D
Supertrend direction is bearish
Price is near or below Supertrend, with an ATR buffer
Price is below the Bollinger Band middle line
This filters for pullbacks within sustained downtrends.
⏰ Trade Execution Logic (Next Day Rule)
Once a setup is confirmed at EOD, a trade is attempted on the next trading session
To avoid chasing gaps:
Long trades are allowed only if price does not move more than a defined multiple of the previous day’s True Range
Short trades follow the same logic in reverse
This is implemented via limit orders, ensuring realistic backtesting and execution behavior
🛑 Risk Management
All exits are volatility-adjusted using ATR:
Stop-Loss:
1.1 × ATR(5) from entry price
Target:
2.2 × ATR(5) from entry price
This results in a risk–reward ratio of approximately 1:2
ATR is frozen at entry to avoid forward-looking bias.
🧠 Why This Strategy Works
Avoids low-quality trades during consolidation
Participates only when trend + momentum align
Prevents emotional gap-chasing
Adapts automatically to changing volatility
Suitable for index futures and liquid stocks
📌 Recommended Usage
Timeframe: Daily
Instruments:
Index Futures (e.g. NIFTY, BANKNIFTY)
Highly liquid stocks
Market Type: Trending markets
Not ideal for: Sideways or low-volatility environments
⚙️ Customization Tips
You can control trade frequency and aggressiveness by adjusting:
RSI thresholds
Supertrend buffer (ATR multiple)
Gap filter multiplier
Stochastic edge parameter
Looser settings → more trades
Stricter settings → higher selectivity
⚠️ Disclaimer
This strategy is for educational and research purposes only.
Backtest results do not guarantee future performance.
Always validate with paper trading before deploying real capital.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
סקריפט קוד פתוח
ברוח האמיתית של TradingView, יוצר הסקריפט הזה הפך אותו לקוד פתוח, כך שסוחרים יוכלו לעיין בו ולאמת את פעולתו. כל הכבוד למחבר! אמנם ניתן להשתמש בו בחינם, אך זכור כי פרסום חוזר של הקוד כפוף ל־כללי הבית שלנו.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.