Login Page - Create Account

Support Board


Date/Time: Thu, 02 May 2024 00:13:30 +0000



[User Discussion] - Using persistant array and also a persistant int variable

View Count: 842

[2015-10-17 05:59:43]
KhaosTrader - Posts: 128
Hi,

I am wondering if I am implementing this code correctly, I am having some problem with my counter..


  s_SwingInfo *p_LongSwings = (s_SwingInfo*)sc.GetPersistentPointer(1);


  int& NbrLongSwings = sc.GetPersistentInt(2);
  int& NbrShortSwings = sc.GetPersistentInt(3);


  if (sc.LastCallToFunction)
  {
    if (p_LongSwings != NULL)
    {
      sc.FreeMemory(p_LongSwings);
      sc.SetPersistentPointer(1, NULL);
    }
    return;

    if (NbrLongSwings != NULL)
    {


      sc.SetPersistentPointer(2, NULL);

    }
  }

  if (sc.UpdateStartIndex == 0)
  {
    NbrLongSwings = 0;
    NbrShortSwings = 0;
  }




  if (p_LongSwings == NULL)
  {
    //Allocate an array of 1024 doubles.
    p_LongSwings = (s_SwingInfo *)sc.AllocateMemory(20000 * sizeof(s_SwingInfo));

    if (p_LongSwings != NULL)
      sc.SetPersistentPointer(1, p_LongSwings);
    else
      return;
  }



[2015-10-18 04:50:45]
KhaosTrader - Posts: 128
I think the above is correct, it seems to be working, I just hoping I doing the cleanup correctly

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

Login

Login Page - Create Account