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.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
How to get an access?
Telegram: t.me/MasterTrendPro
Website: master-trend.pro
Telegram: t.me/MasterTrendPro
Website: master-trend.pro
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.
Açık kaynak kodlu komut dosyası
Gerçek TradingView ruhuyla, bu komut dosyasının mimarı, yatırımcıların işlevselliğini inceleyip doğrulayabilmesi için onu açık kaynaklı hale getirdi. Yazarı tebrik ederiz! Ücretsiz olarak kullanabilseniz de, kodu yeniden yayınlamanın Topluluk Kurallarımıza tabi olduğunu unutmayın.
How to get an access?
Telegram: t.me/MasterTrendPro
Website: master-trend.pro
Telegram: t.me/MasterTrendPro
Website: master-trend.pro
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, alım satım veya diğer türden tavsiye veya öneriler anlamına gelmez ve teşkil etmez. Kullanım Koşulları bölümünde daha fazlasını okuyun.