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. Подробнее читайте в Условиях использования.