OPEN-SOURCE SCRIPT
Online Logistic Forecaster [forexobroker]

Online Logistic Forecaster trains a single-feature logistic regression in real time via stochastic gradient descent. The feature is the standardised price-EMA distance; the target is "next bar closes higher". Each bar updates weight w := w - eta * (sigmoid(w * x) - y) * x. Forecast probability of next-bar up = sigmoid(w * x). Adaptive learning without batch training.
🔶 ALGORITHM
1. EMA = ema(close, len); ATR = atr(14).
2. Feature x = (close - EMA) / ATR (ATR-normalised distance).
3. Online SGD step: y_prev = (close[1] > close[2]); w := w - eta * (sigmoid(w * x[1]) - y_prev) * x[1].
4. Forecast: p_up = sigmoid(w * x).
5. Bull bias when p_up >= upper threshold; bear bias when <= lower threshold.
🔶 SIGNAL LOGIC
- Buy: bull bias edge (cross above upper threshold) AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: bear bias edge.
- Position-lock state machine.
🔶 INPUTS
- Feature EMA Length (default 20)
- Learning Rate eta (default 0.05)
- Buy Probability (default 0.60)
- Sell Probability (default 0.40)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, sigmoid line, buy / sell colors
🔶 ALERTS
OLF Buy, OLF Sell, OLF Any Signal, OLF Bull Edge, OLF Bear Edge, OLF High Conf Up, OLF High Conf Dn, OLF Strong Weight, OLF Webhook JSON.
🔶 LIMITATIONS
- One feature gives a 1D logistic forecast; multi-feature models would be more powerful but require explicit weight management.
- SGD with high eta can oscillate; defaults (eta = 0.05) balance convergence vs adaptation.
- The model needs warm-up of dozens of bars before w stabilises; early bars produce noisy forecasts.
- The "sigmoid line" visual is anchored at the EMA and scaled by ATR — purely informational.
🔶 ALGORITHM
1. EMA = ema(close, len); ATR = atr(14).
2. Feature x = (close - EMA) / ATR (ATR-normalised distance).
3. Online SGD step: y_prev = (close[1] > close[2]); w := w - eta * (sigmoid(w * x[1]) - y_prev) * x[1].
4. Forecast: p_up = sigmoid(w * x).
5. Bull bias when p_up >= upper threshold; bear bias when <= lower threshold.
🔶 SIGNAL LOGIC
- Buy: bull bias edge (cross above upper threshold) AND not already long AND cooldown elapsed AND barstate.isconfirmed.
- Sell: bear bias edge.
- Position-lock state machine.
🔶 INPUTS
- Feature EMA Length (default 20)
- Learning Rate eta (default 0.05)
- Buy Probability (default 0.60)
- Sell Probability (default 0.40)
- Cooldown Bars (default 4)
- Visual: dashboard, glow, sigmoid line, buy / sell colors
🔶 ALERTS
OLF Buy, OLF Sell, OLF Any Signal, OLF Bull Edge, OLF Bear Edge, OLF High Conf Up, OLF High Conf Dn, OLF Strong Weight, OLF Webhook JSON.
🔶 LIMITATIONS
- One feature gives a 1D logistic forecast; multi-feature models would be more powerful but require explicit weight management.
- SGD with high eta can oscillate; defaults (eta = 0.05) balance convergence vs adaptation.
- The model needs warm-up of dozens of bars before w stabilises; early bars produce noisy forecasts.
- The "sigmoid line" visual is anchored at the EMA and scaled by ATR — purely informational.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
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.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
🔵Gain access to our powerful tools : forexobroker.com/tv
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
🔵Join our free telegram for updates : t.me/dominicwalsfxhtrader
All scripts & content provided by Forexobroker are for informational & educational purposes only.
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.