Standard Deviation from Candle Open

This is my first script... so, this isn't too magical. But, what this script does is basically give you 6 multipliers from the open price. The idea is to approximate targets based on the open price of the candle. Intended to use pretty much exclusively for intraday trading. However, all the indicator really is at this point is an indicator that creates a dot at a percentage multiple of the price. So, you can use it as a measuring tool too (i.e. 1% above the open, 2% above the open, etc.) and for most, it may be more useful for that.

My strategy
This strategy is predicated the same principle as Bollinger Bands: the reality that 68% of all data points will fall within one standard deviation of the mean, 96% of all data points will fall within two standard deviations, and 98% of al data points will fall within 3 standard deviations. By understanding the standard deviation, you can possibly infer an edge by understanding the probabilistic range price will be bound to within a specific timeframe. Bollinger Bands are designed to provide this information with the mean being a 20-period moving average and this indicator. However, to be clear, I do not use any Bollinger Band strategies in my trading.

This indicator is designed to provide standard deviation information with the mean being based on the distance price travels away from the open of individual candles in the lookback period.

Now, to do this, it's up to the user to pull the OHLC data, calculate the standard deviation as a percentage of price movement and insert those values in the indicator.

Here's how I personally do it:
I track the OHLC data over a lookback period on a spreadsheet and it does all the math.
I use the "OH % Change" and "OL % Change" over a lookback period as my data set and calculate the standard deviation of those % Changes. This means half the data set is the percent movement of price from the open to the low and the other half is the percentage movement of price from the high. The output then describes one standard deviation from the open price.
I then just calculate the appropriate 1, 2, and 3 standard deviations (i.e. {1/2+1} ) and manually input those values in the settings menu.
This creates the dots which then represent statistically valid targets for the price movement within the period that makes up the candle.

If you use a strategy where you enter on major candle closes, this can be useful to set targets for those entries based on intended hold period or at least add/remove validity to other target metrics.

Your target is at the 1.618 Fibonacci level and your confirmation triggers on the 4h candle close (H4 if that's your thing lol). You set up the indicator based on the standard deviation of price movement in 4h candles over the last week.
Let's say the indicator shows that the 1.618 Fibonacci level is 3 standard deviations away.
This being the case this statistically indicates that within the next 4 hours, you have a very low probability of achieving your target (<2%). This doesn't invalidate your target, but it does indicate a low probability of achieving it in the next 4hrs. With this information, you can infer that you are either going to be (a) really lucky (b) in this trade for a lot longer than 4hrs or (c) your target is unrealistic given your intended hold period.

If (b), then you can calculate the standard deviation on a higher time frame (e.g. 1d-1w) and plot those figures on a said timeframe and estimate your hold period reasonability.

So, you can use it for target setting, a confluence test, a reasonableness test, or just a measurement tool.

Once I actually get good at pinescript, I will do that standard deviation calculation in the indicator so no manual entry will be required. But, the flexibility of entering the multiplier manually is actually really nice too. Maybe you just want to have it hidden and pop it on to get a quick measurement of a percentage range or something. At any rate. I was proud of my first indicator... it's definitely useful to me and I hope you can find some use for it as well.

If you're a beginner at pinescript as I am, maybe you can look at the code and tinker with it to help you along your pinescript journey as well.

Phát hành các Ghi chú: // Title: Standard Deviation from Open Price //
// author: kurtsmock
// TradingView: https://www.tradingview.com/u/kurtsmock/...
// Website: https://www.kurtsmock.com

// Standard Deviation Script
Goal: To establish a mean based on the Open Price and calculate the standard deviation.
The reason for this is if the Open is the mean, then the Standard deviation implies a standardized distance a given candle can be expected to travel
from the open price

Edge: If you know that there is a 68%/95%/99.7% probability that price will NOT move more than
One Standard Deviation/Two Standard Deviations/Three Standard Deviations from the open price respectively
you can set reasonable price targets that relate to those probabilities in a given timeframe.
e.g. if you're on a 1h chart and your target is 3.5% from the open price, but 1 standard deviation of the hourly candle is equal to 0.78%.
You can make assumptions on either:
- The reasonableness of your target
- The holding period likely required for the trade.

Also Standard Deviation is a function of volatility and this tool provides a unique mechanism for measuring volatility as well on a candle by candle basis

Significant changes:
The original script was essentially just a measuring tool. Now the script calculates the standard deviation based on a user-defined lookback period.
You can change the mean source parameter.
You can choose up to 3 standard deviation values and turn on or off

I'm starting to get the hang of this thing... many scripts coming out very soon including:
- Multi-Exchange Volume
- rVol
- Effective Volume
- Active Boundaries
- Buy/Sell Volume
- A Better-er Volume Indicator (=P)
- Delta, Cumulative Delta w/RSI
- Multi-AnchoredVWAP
- and a lot more, so follow my profile if any of that interests you.

... Most are ready to go. But just got to debug, beta test, and make minor changes and I'll be releasing them
Gỡ bỏ khỏi Script Ưa thích Thêm vào Script Ưa thích
Awesome script mate, really appreciate it!
So are the percentages in as 68,95, 99.7?
Phản hồi
kurtsmock olleyg123
@olleyg123, So, I'm new to coding pinescript. This was my first foray. This script is ultimately really a measuring tool. It measures the distance from open. So you need to know the % standard deviation, which at the time I was calculating outside of pinescript. I'll be publishing a new one that will take care of this for you... if you dm me I'll send it to you the code.. just haven't gotten around to publishing it yet. This one though will measure the standard deviation from the beginning of the candle if you know the current sd. The new one calculates it for you and is dynamic (since the SD is always changing candle to candle depending on your lookback period). But yea, keep an eye out. I'm going to be doing a big indicator release coming up, because I have about 10-12 of them now, mostly around volume and price action
+1 Phản hồi
olleyg123 kurtsmock
@kurtsmock, Yeah true. I am familiar with SD's they can be pretty powerful if you know what you are doing aye. Oh that is great! If you have a test I would love to see it, because the estimated SD's would be so helpful :) That is really good you are making so many indicators, it really helps a lot of people!
Phản hồi
kurtsmock olleyg123
@olleyg123, Here's the code =) I'll get it up into tradingview down the road... For this one you input the standard deviation and how long you want to look back to establish the mean data set and it takes care of the rest. Copy/Paste/Save and it will be in your scripts menu

+1 Phản hồi
olleyg123 kurtsmock
@kurtsmock, Thank you heaps, this is working great :) What do you usually set the SD's? I have tried 50 & 100 so far, I think 50 gets price quite well... Thanks again for the help :D
This is how mine is looking:
Phản hồi
kurtsmock olleyg123
@olleyg123, Glad it's working out =) I find that it TOTALLY depends on your timeframe. You can see that my default is 288. that's for down in the 5m timeframe area. It's totally discretionary though. The shorter the lookback period, the fewer data points you are accepting to establish a mean right? So, it's all about going far enough back to get a good data set and not going so far back that you're taking opens from an irrelevant price area. I generally adjust it to somewhere in the area of the nominal range that it's trading in. For example, I would have it start collecting data points about 165 bars back on the BTC 1h chart. Be well.
+1 Phản hồi
olleyg123 kurtsmock
@kurtsmock, Yeah it's great.
Yeah, I understand that it makes sense, you just have to adjust it accordingly...
That is exactly right, thanks for the tips. I like to see how confluent the price action lines up with the 34% regions, similar to what you said.
Awesome stuff, appreciate the support once again. I'll keep you updated if I have any feedback :)
Phản hồi
To clarify exactly what this indicator does, I'll add this.
You'll put this on your chart and the first thing you'll do is hit the settings button and adjust the multiple of +3 sd, +2 sd, and so on,. In the inputs you will see these number:
What these numbers are is a multiple of the open price. So 1.0877 = 1.0877%.
An example is the S&P closed at 2977.62 today. The default settings of the indicator would do this:
(+3 sd):
Phản hồi
kurtsmock kurtsmock
@kurtsmock, well crap.. it trimmed my comment.
2977.62 * 1.0877 = 3238.76
This will be regardless of timeframe. No matter what timeframe you're looking at 8.77% over the open price is still going to be 8.77% above the open price.
I will work on getting this to do the standard deviation automatically and update when I got it
Phản hồi
Indicator with just one standard deviation on the 4h chart demonstrating how any given candle is most likely to stay within one standard deviation of the mean, in this case, opening price.
Phản hồi
Trang chủ Bộ lọc cổ phiếu Bộ lọc Forex Bộ lọc Tiền điện tử Lịch kinh tế Shows Cách thức hoạt động Tính năng Biểu đồ Giá Quy tắc Áp dụng Người điều hành Giải pháp cho Website & Nhà môi giới Widget Giải pháp biểu đồ Thư viện Biểu đồ Lightweight Trung tâm Trợ giúp Giới thiệu bạn Yêu cầu tính năng Blog & Tin tức Câu hỏi thường gặp Wiki Twitter
Hồ sơ Tùy chỉnh Hồ sơ Tài khoản và Thanh toán Giới thiệu bạn Ticket Hỗ trợ của tôi Trung tâm Trợ giúp Các ý tưởng đã đăng Người theo dõi Đang theo dõi Tin nhắn riêng Trò chuyện Đăng xuất