OPEN-SOURCE SCRIPT
HalfTrend Strategy Advanced

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:
✅ Filter Logic (Optimized using Genetic Algorithms)
These filters were selected through computer algorithms to maximize performance on the NIFTY 15M chart, producing significantly improved stats:
⚠️ 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.
📝 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.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。