OPEN-SOURCE SCRIPT

HalfTrend Strategy Advanced

14
This script is part of our educational blog series “How to Convert a TradingView Indicator into an Algo Strategy”, where we enhance a basic HalfTrend strategy using market-aware filters and optimization logic.
📝 Read the full blog series here →
📈 Basic version available here →
🔍 What This Strategy Does
This advanced strategy builds on the original HalfTrend indicator by:
  • Detecting trend reversals based on price structure
  • Filtering entries using a combination of custom RSI and ROC-based conditions

✅ Filter Logic (Optimized using Genetic Algorithms)
  • ROC + RSI behavior for directional confirmation
  • RSI on high and close price for multi-angle strength filtering
  • Built-in logic to dynamically close losing trades when core signal invalidates the setup

These filters were selected through computer algorithms to maximize performance on the NIFTY 15M chart, producing significantly improved stats:
  • Profit Factor > 2
  • Win Rate ~ 50%
  • Sharpe Ratio > 0.35

⚠️ Note
This is a research and educational strategy showcasing how filters can enhance trend-following systems. Not intended for live trading without proper validation and robustness checks.
👉 Follow us for future strategy releases and continue the series in Part 3, where we test strategy robustness and deploy a live strategy portfolio.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.