Login Page - Create Account

Support Board


Date/Time: Sat, 27 Apr 2024 01:12:48 +0000



[Programming Help] - Array Bounds violation in dynamic arrays

View Count: 626

[2019-04-18 05:05:33]
User255315 - Posts: 127
Hi SC,
I have a question regarding dynamic arrays. It might be too vague but this is how i can explain the problem:
I use dynamic arrays to constantly store values pertaining to every price as the session progresses but when there is a new low or high i.e extension in the array size, i get thrown an exception. Would this be related to an array bounds violation? If so, how do i handle it. Even guidelines relating to this are welcome. To clarify further, i am running a loop over hi to lo to calculate said values for every price, and am getting an exception when those lo to hi indexes change.

Thanks in advance.
[2019-04-18 17:58:15]
Sierra Chart Engineering - Posts: 104368
There is no way we can know where you are going wrong unless we were to examine the code and that is not within the scope of our support.
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, *change* to the Teton service:
Sierra Chart Teton Futures Order Routing
[2019-04-27 06:14:42]
User255315 - Posts: 127
Hi SC!
If its possible for you to have just a quick look at the following loop in which i populate a dynamic array with VaP for the range of the day through sc.VolumeAtPriceForBars. I am fairly certain that this loop is throwing the exception. Any suggestions or guidelines regarding this are welcome.


s_VolumeAtPriceV2* p_fill= NULL;
  
  int ProfileIndex = 0;
  int PriceIndex = 0;
  int ht = sc.VolumeAtPriceForBars->GetSizeAtBarIndex(Index)-1;
  
  range[Index] = ht;
    
  for (int KeyIndex = 0;KeyIndex < ht+1; KeyIndex ++)
  {
      sc.VolumeAtPriceForBars->GetVAPElementAtIndex(Index, KeyIndex, &p_fill);

      //verify the pointer is not a null, otherwise an exception will occur
      if (p_fill)
      {
        
        float value= p_fill->Volume;
        p_VAP[KeyIndex]= value;
        //youre storing VAP in dyn mem
      }
    
  }

This is the corresponding error message:
Warning: The Custom DLL study "daily-mod.scsf_SelfContainedVB" has just caused a CPU exception. | 2019-04-26 17:11:59 *
Warning: This Custom DLL study may cause Sierra Chart to be unstable until you remove the study from your chart and restart Sierra Chart. | 2019-04-26 17:11:59 *

Thanks in advance!

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account