kocurekc

Bernoulli Process - Binary Entropy Function

This indicator is the Bernoulli Process or Wikipedia - Binary Entropy Function. Within Information Theory, Entropy is the measure of available information, here we use a binary variable 0 or 1 (P) and (1-P) (Bernoulli Function/Distribution), and combined with the Shannon Entropy measurement. As you can see below, it produces some wonderful charts and signals, using price, volume , or both summed together. The chart below shows you a couple of options and some critical details on the indicator. The best part about this is the simplicity, all of this information in a couple of lines of code.

Using the indicator:
The longer the Entropy measurement the more information you are capturing, so the analogy is, the shorter the signal, the less information you have available to utilize. You'll run into your Nyquist frequencies below a length of 5. I've found values between 9 and 22 work well to gather enough measurements. You also have an averaging summation that measures the weight or importance of the information over the summation period. This is also used for highlighting when you have an information signal above the 5% level (2 sigma) and then can be adjusted using the Percent Rank Variable. Finally, you can plot the individual signals (Price or Volume ) to get another set of measurements to utilize. As can be seen in the chart below, the volume moves before price (but hopefully you already knew that)

At its core, this is taking the Binary Entropy measurement (using a Bernoulli distribution) for price and volume . I've subtracted the volume from the price so that you can use it like a MACD , also for shorter time frames (7, 9, 11) you can get divergences on the histogram. These divergences are primarily due to the weekly nature of the markets (5 days, 10 days is two weeks,...so 9 is measuring the last day of the past two weeks...so 11 is measuring the current day and the past two weeks).

Here are a couple of other examples, assuming you just love BTC , Stocks, or FOREX. I fashioned up a strategy to show the potential of the indicator.
BTC-Strategy

Stock-Strategy (#loveyouNFLX)

FOREX - (for everyone hopped up on 40X leverage)
Release Notes: Added a shoutout to @Picte for his inspiring idea
Release Notes: Added Alerts for Up/Down Triangle Start
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Comments

500 coins
Reply
kocurekc PineCoders
@PineCoders, Wonderful way to ring in the new year, thanks!
Reply
This publication will be featured in our "Best Scripts of The Month" selection. Thank you for your valuable contribution to the TradingView community, and congrats!
+8 Reply
kocurekc PineCoders
@PineCoders, Wow, awesome! #thanksfortheLove
Reply
I AM NOT GETTING SIGNALS ON PRICE CHART ?
+8 Reply
kentskip anantgupta970
@anantgupta970, I am not getting the arrow signals either.
Reply
kocurekc kentskip
@kentskip, @anantgupta970 Thanks for the comments. This is just an indicator and not a strategy which gives you buy and sell signals. You can take this code and turn it into a Tradingview strategy.
https://www.tradingview.com/pine-script-docs/en/v4/essential/Strategies.html?highlight=strategy

You could also add this code to paint bars for a set of rules:
BarColors = input(title="Painting bars", type=input.bool, defval=true)
signal = sma(info2,3)
nColor = BarColors ? signal > 0 and signal >= range ? color.green : signal < 0 and signal <= -range ? color.red : color.blue : na
barcolor(nColor)

+2 Reply
Comment removed.
balipour balipour
@balipour, btw i dont mean its a smooth indicator lol. its just some smooth line. The hvp part is great though.
+1 Reply
kocurekc balipour
@balipour, thank you very much for your comments, you have made some wonderful contributions to the Tradingview community.
Reply
Home Stock Screener Forex Screener Crypto Screener Economic Calendar About Chart Features Pricing Refer a friend House Rules Help Center Website & Broker Solutions Widgets Charting Solutions Lightweight Charting Library Blog & News Twitter
Profile Profile Settings Account and Billing Referred friends Coins My Support Tickets Help Center Private Messages Chat Sign Out