Online Logistic Forecaster is a machine learning indicator TradingView traders can watch learn in public. Also, it runs one logistic regression with a single weight, updated by stochastic gradient descent on every bar. The feature is how far price sits from its 20-period EMA, measured in ATR. Indeed, the output is a probability between zero and one, printed on the dashboard beside the weight the script has learned so far.
It is free and open source. Still, you can add it to any chart from the Online Logistic Forecaster script page on TradingView, and the full Pine source is published there for you to read.
What Online Logistic Forecaster plots on the price chart
Two lines sit on the chart. Thus, a silver 20-period EMA marks the feature’s baseline. A circle plot floats above or below it, placed at the EMA plus the probability minus 0.5, times four ATR. Hence, probability therefore reads as vertical distance. The circles turn mint above 0.5 and crimson below. Next, signals print as stacked diamonds tagged OLF P+ or OLF P-, and the signal bar changes colour. A soft background tint marks bias zones. Then, an eight-row dashboard reports probability, weight, feature, thresholds, position and bars since the last signal.

How Online Logistic Forecaster is built
One feature, one weight
The feature stays simple. Yet, the script takes close minus the 20-period EMA and divides by ATR(14). A positive value means price sits above its own average, measured in ATR. Truly, the model holds exactly one parameter, the weight w, and it starts at zero. There is no intercept term. Plainly, so whenever price sits exactly on the EMA, the forecast reads 0.500 no matter what w has become.
Every bar runs one gradient step. Also, the script forms a prediction with the sigmoid of w times the previous feature, compares it to the label, then applies w := w – eta * (p – y) * x. The learning rate eta defaults to 0.05 and accepts 0.001 to 0.5. Indeed, that is textbook stochastic gradient descent on the logistic loss, one sample per bar. The weight genuinely updates. Still, it is not a decorative label.
Two details deserve a close look. Thus, the label reads 1 when close[1] beats close[2], and the feature used in the update is feat[1], measured on that same bar. Feature and label therefore describe one bar together, so the weight learns how deviation and direction co-occur rather than strictly what follows. The weight also never resets. It carries the whole loaded history, so the number you see depends on how far back your data reaches.
From probability to signal
The forecast for the bar in front of you is the sigmoid of w times the current feature. Hence, above the Buy Probability input, default 0.60, the script flags a bull bias. Below the Sell Probability input, default 0.40, it flags a bear bias. Next, both inputs move freely, from 0.50 to 0.95 on the buy side and 0.05 to 0.50 on the sell side. Between them the dashboard reads NEUTRAL.
Signals fire on the edge, not on the state. Then, a buy needs bull bias on this bar and no bull bias on the one before. Three gates then apply: the position state must not already sit long, at least four bars must have passed since the last signal, and the bar must close. Sells mirror that logic exactly.
Because the model holds a single weight, its whole worldview flips when that weight changes sign. Yet, a positive w means the script has learned that stretched-above-EMA bars tend to be up bars, so it treats extension as bullish. A negative w means it learned the opposite, and the same chart position then reads bearish. Truly, watch the Weight row to know which reading the model currently holds.
How to read the signals
Read the probability as a fitted number, not as odds on a trade. Plainly, it answers one narrow question: given this ATR distance from the EMA, how often did bars like it close green in the history this chart has loaded. With no intercept in the model, the value pins to 0.500 whenever price touches the EMA, and it only travels far when both the weight and the feature grow large.
The Weight row carries more information than the probability. Also, its sign tells you whether the model currently treats extension as continuation or as stretch. Its size tells you how confident the fit has become. Indeed, the script ships an alert for absolute weight above 1.0, which marks the point where modest feature values already push the probability past the thresholds.
Signals need a closed bar, so a diamond lands after the candle completes. Still, they are edge-triggered as well. A probability that sits above 0.60 for thirty bars produces one diamond, not thirty. Thus, the four-bar cooldown then blocks anything that follows too quickly, which suppresses clusters when the feature oscillates around a threshold.

Every Online Logistic Forecaster setting explained
The script exposes 10 inputs, grouped in the settings panel exactly as shown below. Defaults are the published values.
Logistic
| Setting | What it does | Default | Range |
|---|---|---|---|
| Feature EMA Length | Sets the feature ema length used in the calculation. | 20 | 5 to 100 |
| Learning Rate eta | Sets the learning rate eta used in the calculation. | 0.05 | 0.001 to 0.5 |
Signal
| Setting | What it does | Default | Range |
|---|---|---|---|
| Buy Probability | Sets the buy probability used in the calculation. | 0.60 | 0.50 to 0.95 |
| Sell Probability | Sets the sell probability used in the calculation. | 0.40 | 0.05 to 0.50 |
| Cooldown Bars | Sets the cooldown bars used in the calculation. | 4 | 1 to 20 |
Visual
| Setting | What it does | Default | Range |
|---|---|---|---|
| Show Dashboard | Toggles show dashboard on the chart. | on | on / off |
| Show 3-Layer Glow | Toggles show 3-layer glow on the chart. | on | on / off |
| Show Sigmoid Line | Toggles show sigmoid line on the chart. | on | on / off |
| Buy Color (Mint) | Colour used for buy color (mint). | #00e676 | |
| Sell Color (Crimson) | Colour used for sell color (crimson). | #ff1744 |

Alerts built into Online Logistic Forecaster
The script ships 11 alert conditions. Hence, open the alert dialog on the chart, pick the indicator as the condition source, then choose the event you want. Alerts fire on the close of the bar, so they follow the same confirmed-bar rule the on-chart signals use.
- 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
Other markets and timeframes
Nothing in this script is tied to forex. Next, the feature divides by ATR, and the thresholds are probabilities, so both stay unit-free. It uses no volume at all, which means it behaves the same on symbols with no volume feed. Then, gold, indices, crypto and equities all run on the defaults. Two settings deserve a second look per market: the EMA length, which sets what counts as stretched, and the cooldown, since fast charts trigger more edges.

Limitations worth knowing
One feature and one weight cannot represent much. Yet, the model sees ATR distance from an EMA, and nothing else. It holds no view on trend, session, structure or volatility regime. Truly, it runs no intercept, no regularisation and no train-test split, so it fits and predicts on the same stream. The printed probability is an in-sample fit, not an out-of-sample forecast.
The training pair is contemporaneous. Plainly, the header calls the target the next bar’s direction, but the code pairs the feature from bar one back with the direction of that same bar. So the learned relationship describes how deviation and direction sit together. Also, read the output as an adaptive bias meter rather than as a one-bar-ahead prediction.
The weight depends on history length and on the learning rate. Indeed, load more bars and it lands somewhere else. Raise eta from 0.05 towards 0.3 and it chases recent bars, which makes the probability whip across your thresholds. Still, the script also carries no stop, no target and no position sizing, so every risk decision stays yours.
Get Online Logistic Forecaster on TradingView
Open Online Logistic Forecaster on TradingView
If you also trade MetaTrader, the MT4 and MT5 indicator library is available below.
Get the complete indicator library
One email unlocks the full MT4 and MT5 indicator library. Thus, this TradingView script stays free on TradingView – the button above adds it to your chart.
Using it alongside MetaTrader
Adding a script on TradingView takes one click, so there is no install step here. Hence, if you want the same idea on MetaTrader, the MT4 and MT5 indicator installation guide walks through copying files into the data folder and attaching them to a chart. You can also browse the full MetaTrader indicator library, the MT4 indicators section, or the other free TradingView scripts published on this profile. For related chart tools see the MT5 indicators section and the forex trading strategies guides.
External references
- Stochastic oscillator on Wikipedia
- Stochastic Oscillator at Investopedia
- Raff Regression Channel at StockCharts ChartSchool
Frequently asked questions
Does the Online Logistic Forecaster repaint?
The diamonds do not. Next, both signal booleans require barstate.isconfirmed, and the plotshapes read those booleans, so a marker only prints once the bar closes. The probability, the weight and the sigmoid circles do move during the live bar, because the feature uses the current close. Then, they settle when the candle completes.
Is the machine learning label real, or just branding?
It is real, but small. Yet, the script performs genuine stochastic gradient descent on the logistic loss, updating w on every bar with the rule w := w – eta * (sigmoid(w*x) – y) * x. What it does not have is scale. Truly, there is one feature, one weight, no bias term, no batch training and no validation set.
Why does the probability keep sitting near 0.500?
The model has no intercept, so the sigmoid input is simply the weight times the feature. Plainly, near the EMA the feature approaches zero and the output returns to 0.500. Early on the chart the weight is also still small. Also, both effects fade as price stretches and the weight grows.
Which learning rate should I use?
Start at the 0.05 default. Indeed, lower values such as 0.01 keep the weight steady and slow to adapt, which suits higher timeframes. Higher values such as 0.2 make it react to recent bars and produce more threshold crossings. Still, no value makes the fit correct, so change one setting at a time and watch the Weight row.
How much should I rely on this indicator?
Treat it as one input, not a decision. Thus, it is a chart analysis tool, not trading advice. Test it on your own markets and timeframes before relying on it. Results are not guaranteed; past performance is not indicative of future results.
