Login Page - Create Account

Support Board


Date/Time: Tue, 23 Apr 2024 21:16:51 +0000



Post From: unexpected change of persistent variables

[2017-11-25 18:57:05]
User436155 - Posts: 16
hello,

during the development of study i encountered a strange behaviour of my script. index of array stored in persistent variable changed its value to incorrect value unexpectedly. so i could not delete all graphic objects because the index was wrong and some objects remained on chart.

i could not replicate it because i did not know what the trigger is. until yesterday. for sake of simplicity i created an example of code which causes the issue. please see attached picture for explanation.

i think this behaviour affects all persistent variables and changes their values. is this a feature or some kind of bug?

thank you very much anf have a nice day
Jan

example code:

#include "sierrachart.h"

SCDLLName("Persistence Test");

SCSFExport scsf_p_test(SCStudyGraphRef sc)
{
  // set default settings
  if (sc.SetDefaults)
  {
    sc.GraphName = "Persistence Test";
    
    // During development set this flag to 1, so the DLL can be rebuilt without restarting Sierra Chart.
    // When development is completed, set it to 0 to improve performance. The default is 1.
    sc.FreeDLL = 1;

    // auto looping is disabled
    sc.AutoLoop = 0;

    // draw into the main price graph area
    sc.GraphRegion = 0;
    
    return;
  }
  
  SCDateTime & next_request = sc.GetPersistentSCDateTime(1); // get next request time from persistent variable
  
  // real-time check
  SCDateTime time_now = sc.CurrentSystemDateTime;
  
  // creating log
  SCString log_info;
  
  log_info.Format("next request call @ %s", sc.FormatDateTime(next_request).GetChars());
  sc.AddMessageToLog(log_info, 0);

  
  // time for next request? -> process outgoing data
  if (next_request < time_now)
  {
    sc.AddMessageToLog("NEXT REQUEST.. ", 0);
    
    next_request = time_now + 6 * SECONDS;  // set time of next request
  }
  
  return;
}

imagep_test_img.png / V - Attached On 2017-11-25 18:54:39 UTC - Size: 215.27 KB - 344 views