tista

Bayesian BBSMA Oscillator

tista Cập nhật   
Sometime ago (very long ago), one of my tinkering project was to do a spam or ham classification type app to filter news I'd wanna read. So I built myself a Naive Bayes Classifier to feed me my relevant articles. It worked great, I can cut through the noise.

The hassle was I needed to manually train it to understand what I wanna read. I trained it using 50 articles and to my surprise, it's enough.

Complexity Theory

I've been reading a book called The Road to Ruin by Jim Rickards. He described how he got to his conclusion of how the stock market works by using Complexity Theory. Bill Williams would agree. Jim tells us that by using just enough data, we calculate the probability of an event to occur. We can't say for sure when but we know it's coming. This was my light bulb moment.

While Jim talks much about Bayesian Inference in which a probability of an event can always be updated as more evidence comes to light, I had my eyes set on binary probabilities of when prices are going up and down.

Assumptions

These are my assumptions:

  • Prices breaking up a Bollinger basis line will have fuel to go up even higher
  • Prices will go down when prices have broken up a Bollinger upper band
  • Scalping is the main method so we should use a lower period Moving Average (MA)
  • When prices are above MA, it's likelier a correction to the downside is imminent
  • When prices are below MA, it's likelier a correction to the upside is imminent
  • Optimize parameters for 1 hour timeframe which will give us time to react while still having more opportunities to trade

Building Blocks

Jim Rickards started with limited data (events) while in technical trading, data are plentiful. I decided to classify 2 events which are:

  • Next candles would be breaking up
  • Next candles would be breaking down

Key facts:

  • We won't know for sure when prices are going to break
  • We won't know for sure how much the prices movements are going to be

Formulas

Breaking up:

Pr(Up|Indicator) = Pr(Indicator|Up) * Pr(Up) / Pr(Indicator|Up) * Pr(Up) + Pr(Indicator|Down) * Pr(Down)

Breaking down:

Pr(Down|Indicator) = Pr(Indicator|Down) * Pr(Down) / Pr(Indicator|Down) * Pr(Down) + Pr(Indicator|Up) * Pr(Up)

Reading The Oscillator

  • Green is the probability of prices breaking up
  • Red is the probability of prices breaking down
  • When either green or red is flatlining ceiling, immediately on the next candle when the probability decreases go short or long based on which direction you're observing - Strong Signal
  • When either green or red is flatlining ceiling, take no action while it's ceiled
  • Usually when either green or red is flatlining bottom, the next candle when the probability increases, immediately take a short long position based on the direction you're observing - Weak Signal
  • When either green or red is flatlining bottom, take no action while it's bottomed

Alerts

Use Once per Bar option when generating alerts.
Phát hành các Ghi chú:

This update changes how the oscillator is read. After tinkering with the indicator for a bit, I added a new probability called Prime Probability which is a combination of bot classifiers probabilities. A lower threshold is also added to define uncertainty or sideways movements. By adding these, we read the oscillator like below:

  • Sideways or uncertainty is represented when the lower threshold area is colored gray, be very cautious when entering trades in this condition
  • When prime probability changes from zero to a value above the lower threshold, a long signal is fired
  • When breaking up probability changes from 100% to a value less than 100%, a long signal is fired
  • When prime probability changes from a value above the lower threshold to zero, a short signal is fired
  • When breaking down probability changes from 100% to a value less than 100%, a short signal is fired

All the long and short signals are strong signal provided that at the time the signal fires, probabilities tells us we're not in a sideways movement. Weaker signals although excluded from the indicator signals can be determined like below:

  • When prime probability changes from zero or close to zero to a value within the lower threshold, this is a weak long signal
  • When breaking up probability changes from a value above the lower threshold to a value less than the previous candle, this is a weak long signal
  • When prime probability changes from a value within the lower threshold to zero or close to zero, this is a weak short signal
  • When breaking down probability changes from a value above the lower threshold to a value less than the previous, this is a weak short signal

Play around with the lower threshold to find a suitable value. The default values in this indicator are derived from BTCUSDT in Binance at 1H timeframe.
Phát hành các Ghi chú:
This update adds Bill WIlliams indicators to confirm moves. It is disabled by default, more readings about Bill Williams indicators on my blog post below:

https://bango29.com/studying-chaos-and-learning-from-bill-williams/

Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?