Support Board
Date/Time: Wed, 30 Apr 2025 07:37:57 +0000
Can sc.VolumeAtPriceMultiplier be used with multiple study instances?
View Count: 225
[2025-04-14 16:50:50] |
User2069 - Posts: 25 |
I'm trying to write a study that works kind of like a Preset Loader for my chart settings. I want to use multiple instances of the study for all the different configurations and bar periods that i use and i'm assigning each one to an ACS button. This is where i keep running into an issue with sc.VolumeAtPriceMultiplier. Only the value from the last instance of the study that was added gets updated in the chart, even though it is showing in the log like it is reading and assigning the right value from the one i actually click on. I've tried all sorts of checks and even forcing the chart to recalculate right after assigning the input into sc.VolumeAtPriceMultiplier and nothing seems to be working. Is this possible at all?
|
[2025-04-18 01:22:39] |
drinkcodejava - Posts: 29 |
Not totally clear on what you are trying to do or how you are doing it. Your custom study sets sc.VolumeAtPriceMultiplier based on a ACS control bar button on/off state? And the value you are trying to set for sc.VolumeAtPriceMultiplier is study input? Can you post some code? If you are setting sc.VolumeAtPriceMultiplier in each study instance, and you have multiple study instances running on one chart, then you need to have some way of only having one instance set the value you want and prevent the other instances from changing it. Sounds like the value you want is being assigned correctly, but it might be getting changed after that. |
[2025-04-18 07:46:15] |
Sierra_Chart Engineering - Posts: 19383 |
Not sure what the problem is using sc.VolumeAtPriceMultiplier. However, flag to reload the chart: ACSIL Interface Members - Variables and Arrays: sc.FlagToReloadChartData This should not be necessary but maybe that is the problem that the chart is not getting reloaded. It has to be reloaded after changing that variable. But it will happen automatically. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2025-04-18 14:48:35] |
User2069 - Posts: 25 |
I apologize, i guess i should have provided more info. Yes, I'm checking which ACS button is pressed using sc.MenuEventID and then assigning all the values, including sc.VolumeAtPriceMultiplier, when ACS Button On Event is true. I'm getting the values from study input and assigning them to variables. The issue with sc.VolumeAtPriceMultiplier is happening when adding more than one instance of the study to the chart. Only the value from the last instance of the study that was added actually gets updated, even though it is showing the correct values in the log. I think the problem is that sc.VolumeAtPriceMultiplier is getting changed as @drinkcodejava mentioned after the chart finishes reloading , but i'm not sure how or why. The chart was always reloading automatically like it should, i tried forcing it to recalculate more so as troubleshooting to see if it would help, but it didn't unfortunately. I also just gave FlagToReloadChartData a try but it was the same. Here is the main function of the code: if (sc.MenuEventID == SelectedIndex)
{ MessageText.AppendFormat("Got button event id %i, ", sc.MenuEventID); if (sc.PointerEventType == SC_ACS_BUTTON_ON) { MessageText.Append("ACS Button On Event, "); switch(SelectedPeriod) { case 0: NewBarPeriod.IntradayChartBarPeriodType = IBPT_DAYS_MINS_SECS; break; case 1: NewBarPeriod.IntradayChartBarPeriodType = IBPT_VOLUME_PER_BAR; break; case 2: NewBarPeriod.IntradayChartBarPeriodType = IBPT_NUM_TRADES_PER_BAR; break; case 3: NewBarPeriod.IntradayChartBarPeriodType = IBPT_RANGE_IN_TICKS_STANDARD; } if(NewBarPeriod.IntradayChartBarPeriodType == IBPT_DAYS_MINS_SECS) NewBarPeriod.IntradayChartBarPeriodParameter1 = ChartPeriod * 60; else if (NewBarPeriod.IntradayChartBarPeriodType == IBPT_RANGE_IN_TICKS_STANDARD) NewBarPeriod.IntradayChartBarPeriodParameter1 = ChartPeriod * 4; else //sc.GetBarPeriodParameters(NewBarPeriod); NewBarPeriod.IntradayChartBarPeriodParameter1 = ChartPeriod; //Set the bar period parameters. This will go into effect after the study function returns. sc.SetBarPeriodParameters(NewBarPeriod); sc.BaseGraphScaleConstRange = ScaleRange; sc.ConstantRangeScaleModeTicksFromCenterOrEdge = TFC; sc.BaseGraphScaleIncrement = ScaleIncrement; sc.BaseGraphHorizontalGridLineIncrement = GridLineIncrement; sc.VolumeAtPriceMultiplier = VolumeAtPriceMultiplier; // Force the chart to recalculate //sc.RecalculateChart(sc.ChartNumber); sc.FlagToReloadChartData = 1; MessageText.AppendFormat("VolumeAtPriceMultiplier %i, StudyID %i, ", sc.VolumeAtPriceMultiplier, StudyGraphInstanceID); sc.AddMessageToLog(MessageText, 1); // reset button 1 to off if (sc.MenuEventID == SelectedIndex) sc.SetCustomStudyControlBarButtonEnable(SelectedIndex, 0); } else if (sc.PointerEventType == SC_ACS_BUTTON_OFF) MessageText.Append("ACS Button Off Event, "); sc.SetCustomStudyControlBarButtonEnable(sc.PriorSelectedCustomStudyControlBarButtonNumber, 0); } |
[2025-04-18 17:18:55] |
drinkcodejava - Posts: 29 |
And what is your message log output? You are using a different ACS button ID for each instance, correct? Either as a study input or hardcoded? If they are all monitoring the same sc.MenuEventID, then they are all going to set the value on a calculation, and you will just end up with the value set by the last instance in the study list. |
[2025-04-18 18:25:37] |
User2069 - Posts: 25 |
Yes, i'm assigning each instance it's own ACS Button and the corresponding ID through the study input. I've also been checking sc.MenuEventID in the log, as well as the StudyID to make sure it wasn't only applying the values from the last one. Here's the log output after testing with 3 instances of the study: 2025-04-18 14:09:01.734 | Chart: MNQM5.CME [CV][M] 5 Min #2 | Study: Set Chart | Got button event id 1, ACS Button On Event, VolumeAtPriceMultiplier 2, StudyID 19, 2025-04-18 14:09:01.734 | Chart: MNQM5.CME [CV][M] 5 Min #2 | Study: Set Chart | Got button event id 1, ACS Button On Event, VolumeAtPriceMultiplier 2, StudyID 19, 2025-04-18 14:09:01.762 | MNQM5.CME [CV][M] 12.00 Range #2 | Reloading chart. 2025-04-18 14:09:02.060 | MNQM5.CME [CV][M] 12.00 Range #2 | StartDateTimeForLoadingOrderFills: 2024-04-10 00:00:00 2025-04-18 14:09:02.076 | MNQM5.CME [CV][M] 12.00 Range #2 | Chart data loading complete. 2025-04-18 14:09:14.489 | Chart: MNQM5.CME [CV][M] 12.00 Range #2 | Study: Set Chart | Got button event id 2, ACS Button On Event, VolumeAtPriceMultiplier 4, StudyID 20, 2025-04-18 14:09:14.489 | Chart: MNQM5.CME [CV][M] 12.00 Range #2 | Study: Set Chart | Got button event id 2, ACS Button On Event, VolumeAtPriceMultiplier 4, StudyID 20, 2025-04-18 14:09:14.510 | MNQM5.CME [CV][M] 24.00 Range #2 | Reloading chart. 2025-04-18 14:09:14.808 | MNQM5.CME [CV][M] 24.00 Range #2 | StartDateTimeForLoadingOrderFills: 2024-04-10 00:00:00 2025-04-18 14:09:14.821 | MNQM5.CME [CV][M] 24.00 Range #2 | Chart data loading complete. 2025-04-18 14:09:17.146 | Chart: MNQM5.CME [CV][M] 24.00 Range #2 | Study: Set Chart | Got button event id 3, ACS Button On Event, VolumeAtPriceMultiplier 8, StudyID 21, 2025-04-18 14:09:17.146 | Chart: MNQM5.CME [CV][M] 24.00 Range #2 | Study: Set Chart | Got button event id 3, ACS Button On Event, VolumeAtPriceMultiplier 8, StudyID 21, 2025-04-18 14:09:17.193 | MNQM5.CME [CV][M] 5 Min #2 | Reloading chart. 2025-04-18 14:09:17.439 | MNQM5.CME [CV][M] 5 Min #2 | StartDateTimeForLoadingOrderFills: 2024-04-10 00:00:00 2025-04-18 14:09:17.450 | MNQM5.CME [CV][M] 5 Min #2 | Chart data loading complete. Here you can see that VolumeAtPriceMultiplier is displaying the correct values for each one, but it actually remained at 8 the entire time, which was the value set on the last instance of the study. Date Time Of Last Edit: 2025-04-18 18:37:17
|
[2025-04-22 23:20:09] |
drinkcodejava - Posts: 29 |
Definitely something strange going on. I wrote up a simplified version of your study and was able to reproduce the behavior, but what's even more weird is that if you manually change VolumeAtPriceMultiplier (V@PM) manually via Chart Settings >> Chart Data >> Volume At Price to a non-study input value and then try to click a button for any instance other than the last one, the V@PM value doesn't change at all. For example, in the log output you provided, you have Study IDs 19, 20 and 21 with input values of 2, 4 and 8, respectively. For this example, assume that the studies are listed in that calculation order as well. If you enter '12' in the Chart Settings window and then click the button 1 or 2 (i.e. any instance other than the last one), even though the button event and V@PM are output to log, you will see that the value in the Chart Settings window after the chart is reloaded is still 12, not 8 (at least that's how it was when I did it). In other words, the manually entered value only gets changed when the button for the last instance is clicked. If button 1 or 2 is clicked, the value doesn't change from 12 to 2, then to 4, then to 8 as you might think. It actually doesn't change at all. I also wrote up a super simple study (Only Message Log, below) which only outputs the value of V@PM to the message log, and then added two instances into the study list; one near the top above the V@PM studies and one at the bottom. When I did this and clicked the button for the last V@PM instance, the result was the value did not get changed. It's as if even just accessing V@PM in order to write it to output prevents it from getting changed. If I move the second Only Message Log just above the last V@PM instance, the button for the last instance starts working again. I think what you might need to do is in your Preset Loader study, store the desired V@PM value to spreadsheet/file, then develop a separate custom study that reads in and sets the V@PM value, making sure that it is the last in the study list to read/write to sc.VolumeAtPriceMultiplier. SCDLLName("Only Message Log")
SCSFExport scsf_OnlyMsgLog(SCStudyInterfaceRef sc) { SCInputRef i_Input01 = sc.Input[0]; // Section 1 - Set the configuration variables and defaults if (sc.SetDefaults) { sc.GraphName = "Only Message Log"; // sc.StudyDescription = "This is a description that will be displayed on the help page for the study"; sc.AutoLoop = 1; // 1 = Automatic looping is enabled i_Input01.Name = "ID Number"; i_Input01.SetInt(1); return; } // Section 2 - Do data processing here SCString msg; int ID = i_Input01.GetInt(); if (sc.IsFullRecalculation && sc.Index==sc.ArraySize-1) { msg.Format("ID: %d. Current sc.VolumeAtPriceMultiplier value: %d", ID, sc.VolumeAtPriceMultiplier); sc.AddMessageToLog(msg,0); } } |
[2025-04-22 23:30:58] |
Sierra_Chart Engineering - Posts: 19383 |
We think we know what the problem is. We will work on a solution for this.
Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing |
[2025-04-23 20:24:36] |
Sierra_Chart Engineering - Posts: 19383 |
We are adding this new function: int32_t(SCDLLCALL* SetVolumeAtPriceMultiplierForChart)(const uint32_t Multiplier, const int32_t ChartNumber); You will need to use this. Do not use sc.VolumeAtPriceMultiplier. It will become read-only. Sierra Chart Support - Engineering Level Your definitive source for support. Other responses are from users. Try to keep your questions brief and to the point. Be aware of support policy: https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation For the most reliable, advanced, and zero cost futures order routing, use the Teton service: Sierra Chart Teton Futures Order Routing Date Time Of Last Edit: 2025-04-23 20:24:50
|
[2025-04-24 11:53:58] |
User2069 - Posts: 25 |
Just updated to 2755 and gave the new function a try. It's working perfectly now, thank you so much! You guys are awesome! Also @drinkcodejava thank you for your help as well, i really appreciate it! |
To post a message in this thread, you need to log in with your Sierra Chart account: