Support Board
Date/Time: Sat, 23 Nov 2024 19:45:10 +0000
[User Discussion] - Set Volume-by-Price "Ticks per volume bar" by setting exact number of VbP bars on chart?
View Count: 496
[2023-08-04 15:48:30] |
funbun - Posts: 90 |
I found that a big portion of my clicks are changing the "ticks-per-volume" for each chart and again for each ticker. I also found that all I'm aiming is to get to a specific VbP bar density that is clear and readable. Is there a way to automatically set the "ticks per volume bar" just by giving a number of VbP bars I want to see on the chart? Ideally, there could also be +/- buttons on the Control Bar to adjust that number (more or less VbP bar density) That would save many unnecessary clicks that could otherwise be automated. I'm sure this is also relevant for Futures traders, automatically adjusting the VbP according to changes in volatility. Date Time Of Last Edit: 2023-08-04 15:49:02
|
[2023-08-04 19:22:48] |
Tony - Posts: 516 |
1, automatically adjusting the VbP according to changes in volatility
That is incorrect, VbP's Ticks Per Volume Bar should always set as 1 tick, regardless of volatility.2, Is there a way to automatically set the "ticks per volume bar" just by giving a number of VbP bars I want to see on the chart
no, because each session's range is different.3, Ideally, there could also be +/- buttons on the Control Bar to adjust that number (more or less VbP bar density)
yes, you can set "Tick Per Volume" by a ACSIL fuction called "sc.SetChartStudyInputInt()"Sample code: #include "sierrachart.h" SCDLLName("VbP_Tick") SCSFExport scsf_VbP_Tick(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Change VbP Tick Number"; sc.GraphRegion = 0; sc.UpdateAlways = 1; sc.ReceiveCharacterEvents = 1; sc.AutoLoop = 1; return; } int VbP_ID {1}; int Tick_Number {1}; // change Tick_Number based on keyboard input, + to increase, - to decrease if (sc.CharacterEventCode==43) { Tick_Number = min(50, Tick_Number+1); sc.SetChartStudyInputInt(sc.ChartNumber, VbP_ID, 31, Tick_Number); } if (sc.CharacterEventCode==45) { Tick_Number = max(1, Tick_Number-1); sc.SetChartStudyInputInt(sc.ChartNumber, VbP_ID, 31, Tick_Number); } } Date Time Of Last Edit: 2023-08-05 10:42:36
|
[2023-08-04 19:36:56] |
funbun - Posts: 90 |
That is incorrect, VbP's Ticks Per Volume Bar should always set as 1 tick, regardless of volatility.
I don't understand what you mean by that. It is one of the very first options on the VbP settings. Why always use 1 tick? is soundslike a visual preference of yours. I'll try to explain visually and you'll tell me if I'm wrong - I've attached two identical charts with the difference being the "ticks per volume" settings. One is set to 1 tick and one is set to 20 ticks. Obviously the one set to 1 VbP bar each 20 ticks is much better. All I'm saying is that VbP bar "density" could be set automatically if we have the possibility to set the number of VbP bars we want to see on the chart. And that density will stay the same regardless of the price range displayed on the chart. By the way, all the numbers you see on the Control Bar are only to change this tick parameter... Date Time Of Last Edit: 2023-08-04 19:37:57
|
[2023-08-04 20:06:38] |
Tony - Posts: 516 |
Now it makes sense, I didn't know you're trading stocks. Please ignore my 1st answer, that applies for futures products
|
[2023-08-05 21:20:34] |
Tony - Posts: 516 |
@funbun just in case, if you haven't figured it out yet, I tested the code below, it works very well on my Sierra window, the study increase/decrease VbP's tick number by pressing "+" or "-" on number key pad. (you will need to change the VbP study ID accordingly, depends on how you load your VbP study, also the number goes from 1 cent to 50 cents, you can change the high end of the range too) Thanks for sharing the tip of making stock profile smoother! #include "sierrachart.h" SCDLLName("VbP_Tick") SCSFExport scsf_VbP_Tick(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Change VbP Tick Number"; sc.GraphRegion = 0; sc.UpdateAlways = 1; sc.ReceiveCharacterEvents = 1; sc.AutoLoop = 1; return; } int VbP_ID {3}; static int Tick_Number {1}; // change Tick_Number based on keyboard input, + to increase, - to decrease if (sc.CharacterEventCode==43) { Tick_Number = min(50, Tick_Number+1); sc.SetChartStudyInputInt(sc.ChartNumber, VbP_ID, 31, Tick_Number); sc.RecalculateChart(sc.ChartNumber); } if (sc.CharacterEventCode==45) { Tick_Number = max(1, Tick_Number-1); sc.SetChartStudyInputInt(sc.ChartNumber, VbP_ID, 31, Tick_Number); sc.RecalculateChart(sc.ChartNumber); } } Date Time Of Last Edit: 2023-08-05 21:27:10
|
[2023-08-08 07:48:23] |
funbun - Posts: 90 |
Amazing work here Tony, I will definitely use this code to replace my endless CB buttons... But, I was referring to something else.. A way to completely remove the need to change the VbP ticks parameter, here's how - Instead of adjusting the tick size for each new stock, set a fixed number of horizontal VbP bars on a chart. Example - Set VbP bars to 40 horizontal VbP bars per chart For a high range stock If the stock has a chart range from $20 to $30, the VbP ticks parameter will set itself automatically to (30-20)/40 = 25 ticks per VbP bar For a low range stock If the stock has a chart range from $2 to $2.80, the VbP ticks parameter will set itself automatically to (2.8 - 2)/40 = 2 ticks per VbP bar This automation removed the need to adjust the VbP ticks parameter when switching from a high range stock to a low range stock and vice versa. The number 40 represents the exact VbP bars "density" that's not too fine and not too thick, but it can be any number. Does it make sense? Date Time Of Last Edit: 2023-08-08 07:51:18
|
[2023-08-08 15:36:55] |
Tony - Posts: 516 |
Sorry funbun, I am not familiar with stocks. Back to your 2 screen shots: usm1.png is the most accurate profile, it is the reality, the problem is there are too many volume spikes that complicate the decision making process, set a higher tick number is basically to average out/blur the reality a little bit, and actually give us a "big picture" where volumes are distributed, shows in usm2.png. If you already tested the "40 horizontal bars" visual effect, here is the code that based on that idea, so you don't have to do anything, tick number is adjusted automatically, I haven't tested yet: #include "sierrachart.h" SCDLLName("VbP_Tick") SCSFExport scsf_VbP_Tick(SCStudyInterfaceRef sc) { if (sc.SetDefaults) { sc.GraphName = "Change VbP Tick Number"; sc.GraphRegion = 0; sc.UpdateAlways = 1; //sc.ReceiveCharacterEvents = 1; sc.AutoLoop = 1; return; } int VbP_ID {6}; int Tick_Number {1}; static float TheHighestBuffer {0.0}; static float TheLowestBuffer {0.0}; int FirstIndex {sc.GetFirstIndexForDate(sc.ChartNumber, sc.BaseDataEndDateTime[sc.Index].GetDate())}; float TheHighest {sc.GetHighest(sc.High, sc.Index, sc.Index-FirstIndex)}; float TheLowest {sc.GetLowest(sc.Low, sc.Index, sc.Index-FirstIndex)}; if (!sc.Index) { TheHighestBuffer = 0.0; TheLowestBuffer = 0.0; } if (TheHighestBuffer != TheHighest || TheLowestBuffer != TheLowest) { Tick_Number = int ((TheHighest - TheLowest) / 40.0); sc.SetChartStudyInputInt(sc.ChartNumber, VbP_ID, 31, Tick_Number); sc.RecalculateChart(sc.ChartNumber); TheHighestBuffer = TheHighest; TheLowestBuffer = TheLowest; } } Unfortunately, I don't have the answer to your question, hope you will find the best option to address this. Date Time Of Last Edit: 2023-08-08 17:08:48
|
[2023-08-08 15:58:29] |
funbun - Posts: 90 |
That code you wrote above is exactly what I was talking about :) How can I thank you? In the meantime I named the study after you I'm not a coder but reading it I understand the logic... I bothered you enough but it doesn't work when I load it up on a chart.. I just need it to recalculate once when the ticker changes Many thanks! Date Time Of Last Edit: 2023-08-08 15:59:10
|
[2023-08-08 17:06:03] |
Tony - Posts: 516 |
no worries man, really just a simple code, I am glad it works. I added " if (!sc.Index) {}" block in post #7, maybe you don't need init. recalculation anymore. Date Time Of Last Edit: 2023-08-19 13:18:04
|
To post a message in this thread, you need to log in with your Sierra Chart account: