Support Board
Date/Time: Sun, 24 Nov 2024 01:54:31 +0000
[User Discussion] - Price changes count within bar
View Count: 6344
[2013-12-21 15:47:22] |
tbwebb2 - Posts: 19 |
I want to create a study that can count the number of price changes at the tick level within a given bar. My understanding is that "tick volume" is the number of trades that occurred, not the number of price changes. I will be using this for Futures trading if it makes a difference. Is there a study that already does this? If not, what function would I use to count the price changes when programming the study?
|
[2013-12-21 16:23:11] |
Sawtooth - Posts: 4118 |
Use the Uptick Volume and Downtick Volume studies.
|
[2013-12-21 16:31:52] |
tbwebb2 - Posts: 19 |
From the technical studies reference: Uptick volume is the volume of trades that occurred at a higher price than before. Unless I'm misunderstanding this, it isn't really what I'm looking for. I want a study that counts the number of price changes within a bar. Number of trades shouldn't be a factor. |
[2013-12-21 22:42:11] |
Sawtooth - Posts: 4118 |
It's actually the volume not the # of trades, but you are correct that it isn't what you want. However, assuming price doesn't move unless a trade is made, you could divide the uptick volume by the trades at ask (and downtick volume by the trades at bid), then the sum of the two would approximate the number of price changes per bar. Here is an example spreadsheet and study collection that does this. The total price changes per bar is in column M. Put the attached in your Sierra Chart \Data folder, open a new chart, and go to Analysis >> Price chg per bar- |
Price chg per bar.scwbf - Attached On 2013-12-21 22:40:48 UTC - Size: 347.17 KB - 622 views Price chg per bar-.StdyCollct - Attached On 2013-12-21 22:41:17 UTC - Size: 46.57 KB - 646 views |
[2013-12-22 05:36:11] |
tbwebb2 - Posts: 19 |
Thanks for the help. It seems like the value you are calculating is actually the average volume per trade? In your spreadsheet if you take (Volume/ # of trades)*2, it returns similar values as in your total price changes column.
|
[2013-12-22 14:43:13] |
Sawtooth - Posts: 4118 |
The Uptick/Downtick volume is slightly different than the Ask/Bid volume, so separated they will be slightly different, but summed they would be the same. I realize this isn't what you want, but it's a very rough approximation.
|
[2013-12-22 19:58:22] |
tbwebb2 - Posts: 19 |
Ok I see. Is it possible to write a function that could go in at the tick level and count each time price changes within a bar?
|
[2013-12-22 23:04:52] |
Zosimus - Posts: 345 |
I think this can be a start. It displays the counter of the price changes of the last bar as text to the right side of the bar. You can use the inputs of the study to shift the text to the right and to change the font size. You can use the Subgraphs to change the color. Notice that sometimes price pluctuates faster than you can see so the counter might jump a few numbers up while you thought you only saw one price movement. Anyway, check it to see if it works like you want it to (I am not a professional programmer). I am attaching the .CPP file (Source file). You will have to build it on your Sierra Chart. |
PriceChangeCounter.cpp - Attached On 2013-12-22 23:02:32 UTC - Size: 2.53 KB - 716 views |
[2013-12-22 23:21:16] |
tbwebb2 - Posts: 19 |
Thanks, this is a great start! I was looking for a study that could show me the price change counts for past bars as well, not just the present bar. Is this possible to program? Eventually I want to be able to compare the number of price changes within a bar to how far price actually moved from open to close within the bar to see how much imbalance there was between buyers and sellers. Larger price move with fewer price changes = larger demand/supply imbalance Smaller price move with more price changes = smaller demand/supply imbalance |
[2013-12-22 23:38:11] |
Zosimus - Posts: 345 |
I'll give it some thought tomorrow. it's too late for thinking on my side of the globe :-)
|
[2013-12-23 13:17:47] |
Zosimus - Posts: 345 |
Hi, I don't know how to get correct price movement counting for past bars because I don't know how to access the tick by tick changes within the past bars BUT I can change the code to show the price movement counting for all bars from the moment you start your SC and forward. (You can get the results for past bars by running a Chart Replay). I am attaching 2 files. 1. PriceChangeCounter_1 - This study shows the counting of the price movements for all the bars from the moment you start the study. The numbers are displayed as Bars (Place the study on one the of the regions below the price). 2. Changes_Movement_Ratio - This study calculates the Ratio between the total Movement that the bar made from Open to Close and the number of price movemenmts that happened within the Bar. So if price moved 10 ticks from open to close and there were 40 price changes during the bar then you will get 10/40 = 0.25 . I think this is what you meant when you wrote "Eventually I want to be able to compare the number of price changes within a bar to how far price actually moved from open to close within the bar to see how much imbalance there was between buyers and sellers." This study also displays the results for all the bars from the moment you start the study and forward. Date Time Of Last Edit: 2013-12-23 13:20:32
|
PriceChangeCounter_1.cpp - Attached On 2013-12-23 13:17:16 UTC - Size: 1.71 KB - 663 views Changes_Movement_Ratio.cpp - Attached On 2013-12-23 13:17:40 UTC - Size: 1.87 KB - 652 views |
[2013-12-23 14:13:49] |
tbwebb2 - Posts: 19 |
This is great! Thanks so much for the help. I'm going to tinker with the code myself, see if I can up with a formula more accurate than (Price delta)/(Price changes count). Also a way to differentiate bullish vs bearish imbalances, not just how much imbalance there currently is. Thanks again! |
[2013-12-23 14:16:02] |
Zosimus - Posts: 345 |
:-) Good luck :-) Let me know if I can help. Date Time Of Last Edit: 2013-12-23 14:16:20
|
[2013-12-23 18:20:25] |
tbwebb2 - Posts: 19 |
Quick question- how come the price change counter shows a lot of bars having zero price changes even though price clearly moved within the bar?
|
[2013-12-23 18:35:46] |
Zosimus - Posts: 345 |
are you sure you are looking at the price change counter? Could it be that you are looking at the Changes_Movement_ratio study instead ?
|
[2013-12-23 18:37:30] |
tbwebb2 - Posts: 19 |
I'm looking at the price change counter. It has quite a few zero values, which then obviously also results in the ratio study having zero values as well. I'm using bars of 5000 volume, not time bars if that makes a difference.
|
[2013-12-23 18:45:22] |
Zosimus - Posts: 345 |
What kind of values are you seeing on the price change counter study (do you see fractions?)
|
[2013-12-23 18:48:09] |
tbwebb2 - Posts: 19 |
I'm getting values anywhere between 0 and 20. No fractions, all integers.
|
[2013-12-23 19:06:23] |
Zosimus - Posts: 345 |
This is strange, here is an image of a replay I made on a 5000 Volume chart of the ES for this morning. I see no Zeros on the PriceChangeCounter. The Changes_Movement_Ratio study does have zeros when the Open and close are the same. http://screencast.com/t/1WdDMxwB What instrument are you looking at ? Other than that I did find one bug on the Changes_Movement_Ratio study. Please delete the previous one and then save and build this one instead. |
Changes_Movement_Ratio.cpp - Attached On 2013-12-23 19:06:03 UTC - Size: 1.87 KB - 560 views |
[2013-12-23 19:17:06] |
tbwebb2 - Posts: 19 |
I'm looking at the ES as well. Here is a picture of what I'm seeing: http://i.imgur.com/DC6ONec.png Surely I must just have a setting different than you somewhere? |
[2013-12-23 19:32:08] |
Zosimus - Posts: 345 |
ok, lets start with deleting both studies from your ACS_SOURCE folder. Then download them again from here and build them again. remove the old studies from the chart and load those new ones after you have built them. Let me know if you still have this problem after those steps. Second thing, what do you have on your Data/Trade Service settings for the "Intraday Data storage Time Unit" ? |
Changes_Movement_Ratio.cpp - Attached On 2013-12-23 19:30:42 UTC - Size: 1.87 KB - 662 views PriceChangeCounter_1.cpp - Attached On 2013-12-23 19:31:04 UTC - Size: 1.71 KB - 648 views |
[2013-12-23 19:51:28] |
Zosimus - Posts: 345 |
ok, I think I found the problem. When you run the Replay, choose on the replay window "Accurate trading system Back Test Mode", instead of "Standard replay".
|
[2013-12-23 20:36:24] |
tbwebb2 - Posts: 19 |
That worked! Thanks again!
|
[2013-12-23 20:37:15] |
Zosimus - Posts: 345 |
Pleasure :-)
|
[2013-12-24 19:14:25] |
tbwebb2 - Posts: 19 |
Would it be possible to add a moving average to the ratio study perhaps with the option to choose between SMA, EMA, and WMA?
|
To post a message in this thread, you need to log in with your Sierra Chart account: