OPEN-SOURCE SCRIPT
Master Trend AI

Master Trend · AI is a standalone overlay companion to the Master Trend indicator. It runs three independent machine-learning algorithms on the same channel features and consolidates their signals into a single on-chart table.
─── How it works ───
KNN Lorentzian Classifier
Searches the last N bars for the k historical states most similar to the current market (RSI, smoothed RSI, ATR ratio, position inside the Master Trend channel). Each matched bar is labelled bullish or bearish based on its 4-bar forward return. The majority vote determines the prediction and confidence score.
Linear Regression Forecast
Fits a least-squares line to the last N closing prices and projects it forward. A dashed line on the chart shows the projected price target. The table shows the expected percentage change from the current close.
Naive Bayes Classifier
Estimates Gaussian probability distributions of RSI and volatility features, separately for bull and bear historical bars. Applies Bayes' theorem via log-likelihood to produce a calibrated probability P(bull) / P(bear).
─── Table (top-right corner) ───
Three columns — KNN · LinReg · Bayes — with three rows:
─── Setup ───
─── Alerts ───
─── Notes ───
─── How it works ───
KNN Lorentzian Classifier
Searches the last N bars for the k historical states most similar to the current market (RSI, smoothed RSI, ATR ratio, position inside the Master Trend channel). Each matched bar is labelled bullish or bearish based on its 4-bar forward return. The majority vote determines the prediction and confidence score.
Linear Regression Forecast
Fits a least-squares line to the last N closing prices and projects it forward. A dashed line on the chart shows the projected price target. The table shows the expected percentage change from the current close.
Naive Bayes Classifier
Estimates Gaussian probability distributions of RSI and volatility features, separately for bull and bear historical bars. Applies Bayes' theorem via log-likelihood to produce a calibrated probability P(bull) / P(bear).
─── Table (top-right corner) ───
Three columns — KNN · LinReg · Bayes — with three rows:
- Signal — ▲ BULL / ▼ BEAR / ● NEUT (LinReg shows ▲ UP / ▼ DOWN)
- Strength — KNN: vote confidence %; LinReg: projected Δ%; Bayes: class probability %
- Detail — KNN: votes / k; LinReg: target price; Bayes: raw p-value
─── Setup ───
- Add Master Trend to the chart.
- Add Master Trend · AI as a second overlay on the same chart.
- Open the "Trend (sync with Master Trend)" group and match Length and Multiplier to your Master Trend settings. The AI channel feature depends on these values being identical.
─── Alerts ───
- AI+Trend LONG — KNN predicts bullish and Master Trend fires a long signal simultaneously.
- AI+Trend SHORT — KNN predicts bearish and Master Trend fires a short signal simultaneously.
─── Notes ───
- All three models are recalculated on every bar from scratch — no external data, no repainting from lookahead.
- KNN and Naive Bayes share the same Lookback / Step parameters for consistency; LinReg has its own length.
- Signals become active after Lookback bars have elapsed from the chart's first bar.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
How to get an access?
Telegram: t.me/MasterTrendPro
Website: master-trend.pro
Telegram: t.me/MasterTrendPro
Website: master-trend.pro
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
How to get an access?
Telegram: t.me/MasterTrendPro
Website: master-trend.pro
Telegram: t.me/MasterTrendPro
Website: master-trend.pro
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。