Login Page - Create Account

Support Board


Date/Time: Tue, 24 Dec 2024 17:23:54 +0000



Post From: persistant array of structs

[2015-10-29 23:57:45]
KhaosTrader - Posts: 128
Ok I had some troubles, I had to remove the dll from the chart and re-apply it...

I rewrote the code here, please tell me if its correct, I am using 2 arrays, and 2 counter int vars...




  s_SwingInfo* p_LongSwings = (s_SwingInfo*)sc.GetPersistentPointer(1);
  s_SwingInfo* p_ShortSwings = (s_SwingInfo*)sc.GetPersistentPointer(2);
  int& NbrLongSwings = sc.GetPersistentInt(3);
  int& NbrShortSwings = sc.GetPersistentInt(4);

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



  if (sc.LastCallToFunction)
  {


    if (p_LongSwings != NULL)
    {
      delete p_LongSwings;
      sc.SetPersistentPointer(1, NULL);
    }

    if (p_ShortSwings != NULL)
    {
      delete p_ShortSwings;
      sc.SetPersistentPointer(2, NULL);
    }

    if (NbrLongSwings != NULL)
    {
      sc.SetPersistentPointer(3, NULL);
    }



    if (NbrShortSwings != NULL)
    {
      sc.SetPersistentPointer(4, NULL);
    }



    return;
  }







  if (p_LongSwings == NULL)
  {
    //Allocate an array of 20k structs.

    p_LongSwings = (s_SwingInfo *) new s_SwingInfo[20000];
    if (p_LongSwings != NULL)
      sc.SetPersistentPointer(1, p_LongSwings);
    else
      return;
  }

  if (p_ShortSwings == NULL)
  {
    //Allocate an array of 20k structs.
    p_ShortSwings = (s_SwingInfo *) new s_SwingInfo[20000];
    if (p_ShortSwings != NULL)
      sc.SetPersistentPointer(2, p_ShortSwings);
    else
      return;
  }



Date Time Of Last Edit: 2015-10-30 00:19:16