Login Page - Create Account

Support Board


Date/Time: Tue, 07 May 2024 04:42:11 +0000



Post From: SC 1316 Errors While Trading

[2015-11-11 14:32:50]
umair1 - Posts: 86
Thanks, I have a few questions:

I really wanted to use a block like catch(exception& e) and then use e.what() so I could see what exactly the exception is. But I was unable to get this to work in SC.

I suppose I could use the block of code you provided and then group different parts of my code with different log messages to figure out which block is causing the problem, but when I tried to compile the block given above I got the following build error:

error: exception handling disabled, use -fexceptions to enable

Why is exception handling disabled? It would be helpful if we could turn it back on in SC.

To circumvent this, I compiled from the windows cmd command line. I copied the G++ build statement from the "build custom studies" window in SC and simply replaced the -fno-exceptions with -fexceptions.

I put try/catch blocks in all my custom studies around all the code outside of the "if (sc.SetDefaults)" if statement but I never get any exceptions thrown from my custom studies.

But I still get exceptions from Sierra Chart. Lately I have been getting the following error:

Warning: Caught an exception during the processing of a timer event. | 2015-11-11 06:19:05 *

which repeats over and over for a few minutes. I get this error from simply switching between charts or pushing F5 or F6. Some of the SC menu options become unresponsive after getting this error.

But I never get exceptions thrown from my custom studies. I wanted to test whether or not SC even reports a thrown exception from a custom study so I built the following:

#include "sierrachart.h"

SCDLLName("test exceptions")

SCSFExport scsf_renko_overlay(SCStudyInterfaceRef sc)
{
  SCSubgraphRef test = sc.Subgraph[0];

  if (sc.SetDefaults)
  {
    sc.GraphName = "test exceptions";
    sc.StudyDescription = "test exceptions";
    sc.AutoLoop = 1;
    sc.FreeDLL=1;
    return;
  }

  try
  {
    //Define an array of variables within the function. This is created on the "stack"
int IntegerArray[4] = {1, 2, 3, 4};

//The following line will corrupt the stack because it is accessing beyond the bounds of the array
IntegerArray[4] = 10;
  }
  catch(...)
  {
    sc.AddMessageToLog("Exception caught in test exceptions study",0);
  }
}

This is the stack corruption example copied straight from: https://www.sierrachart.com/index.php?page=doc/helpdetails17.html#h17.1

This code doesn't throw an exception. The only time I receive an exception from a custom study is if I explicitly throw one ie

throw "exception test";

So I need better tools/methods to debug my custom studies because if they are causing problems, they aren't significant enough to cause exceptions. I will try running in ACS safe mode for a few days and see if all the exception errors go away.