Login Page - Create Account

Support Board


Date/Time: Mon, 21 Apr 2025 17:05:19 +0000



Post From: Can sc.VolumeAtPriceMultiplier be used with multiple study instances?

[2025-04-18 14:48:35]
User2069 - Posts: 24
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);

    }