Login Page - Create Account

Support Board


Date/Time: Thu, 16 Jan 2025 16:04:37 +0000



CPU exceptions from a custom study after switching to the SC+CTS combo

View Count: 1300

[2017-11-11 08:37:17]
Zosimus - Posts: 345
I've just switched to the SC+CTS combo and since then one of my custom study started generating cpu exceptions. This study uses the
sc.GetTimeAndSales()
sc.GetAskMarketDepthStackPullValueAtPrice()
and s_UseTool
Before this I used Rithmic with no problems. Does this make any sense?
[2017-11-11 09:37:08]
Sierra Chart Engineering - Posts: 104368
It makes no sense for this to be related to the particular service being used other than the fact that the CTS symbols are going to be longer and that maybe is causing some problem in your own code.


You need to check for a problem in your code.

If the problem started happening after updating Sierra Chart, see if recompiling on that version solves it, but if it does we need to know.
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
Date Time Of Last Edit: 2017-11-11 09:38:40
[2017-11-11 11:01:35]
Zosimus - Posts: 345
I did upgrade from 1635 to the latest when I configured the CTS connection but the first thing I did when the problem started was to go back to 1635 and to rebuild the study on 1635. this didnt help.
I will check the code.
Date Time Of Last Edit: 2017-11-11 11:01:59
[2017-11-11 23:12:01]
Zosimus - Posts: 345
I've narrowed down the cause of the CPU exception errors to a portion of the code that iterates through the TimeAndSales array.
It uses the Type, Sequence, Volume and Price members of the s_TimeAndSales structure.
This portion of the code does not use the sc.GetChartName() function so I dont think it has to do with the fact that the CTS symbols are longer than Rithmic's.
The study works fine with Rithmic symbols and also with SC Data - All Services symbols.

This is the code portion that generates the CPU Exceptions

  // ++++++++++++++++Iterate through the Time and Sales and process unprocessed entries++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +
  
  if (LastProcessedSequence != 0) {
    int TnsLoopArrayIndex, CumulativeAskAbsorptionArrayIndexToReset, CumulativeBidAbsorptionArrayIndexToReset;
    for (int TSIndex = 0; TSIndex < TimeSales.Size(); ++TSIndex) {
      if (TimeSales[TSIndex].Sequence <= LastProcessedSequence) continue; //jump to next loop cycle if we have no new T&S entries to process      
      if (TimeSales[TSIndex].Type == SC_TS_ASK) {
        TnsLoopArrayIndex = (int)(TimeSales[TSIndex].Price / sc.TickSize) - ArrayPriceDifference;
        CumulativeAskAbsorptionArrayIndexToReset = (int)((TimeSales[TSIndex].Price - (float)Cumulative_Absorption_Tolerance.GetInt() * sc.TickSize) / sc.TickSize) - ArrayPriceDifference;


        if (TimeSales[TSIndex].Price > HighestRecentAskAbsPrice) HighestRecentAskAbsPrice = TimeSales[TSIndex].Price;
        else if (TimeSales[TSIndex].Price < LowestRecentAskAbsPrice) LowestRecentAskAbsPrice = TimeSales[TSIndex].Price;

        if (p_RecentAskAbsToBeErased[TnsLoopArrayIndex] == 1) {// in order to erase the recent abs only when we get back to them we remember that we have to ersae them as "1" and then erase only when we get back to them
          p_AskRecentAbsorptions[TnsLoopArrayIndex] = 0;
          p_RecentAskAbsToBeErased[TnsLoopArrayIndex] = 0;
        }
        p_AskRecentAbsorptions[TnsLoopArrayIndex] += TimeSales[TSIndex].Volume; // acumulate just after reseting if had to get reset

        if (Aggression_Meter_Reset_Mode.GetIndex() == 0 && TimeSales[TSIndex].Price != LastAskTradePrice) Buyers_Meter = 0;
        Buyers_Meter += TimeSales[TSIndex].Volume;


        if (TimeSales[TSIndex].Price != LastAskTradePrice) {
          p_RecentAskAbsToBeErased[(int)(LastAskTradePrice / sc.TickSize) - ArrayPriceDifference] = 1; // mark it as has to be reset for ther next time it becomes the ask                  
        }

        p_AskCumulativeAbsorptions[TnsLoopArrayIndex] += TimeSales[TSIndex].Volume;
        p_AskTotalAbsorptions[TnsLoopArrayIndex] += TimeSales[TSIndex].Volume;        

        LastAskTradePrice = TimeSales[TSIndex].Price;
      }


      else if (TimeSales[TSIndex].Type == SC_TS_BID) {
        TnsLoopArrayIndex = (int)(TimeSales[TSIndex].Price / sc.TickSize) - ArrayPriceDifference;
        CumulativeBidAbsorptionArrayIndexToReset = (int)((TimeSales[TSIndex].Price + (float)Cumulative_Absorption_Tolerance.GetInt() * sc.TickSize) / sc.TickSize) - ArrayPriceDifference;


        if (TimeSales[TSIndex].Price < LowestRecentBidAbsPrice) LowestRecentBidAbsPrice = TimeSales[TSIndex].Price;
        else if (TimeSales[TSIndex].Price > HighestRecentBidAbsPrice) HighestRecentBidAbsPrice = TimeSales[TSIndex].Price;

        if (p_RecentBidAbsToBeErased[TnsLoopArrayIndex] == 1) {
          p_BidRecentAbsorptions[TnsLoopArrayIndex] = 0;
          p_RecentBidAbsToBeErased[TnsLoopArrayIndex] = 0;
        }

        p_BidRecentAbsorptions[TnsLoopArrayIndex] += TimeSales[TSIndex].Volume;

        if (Aggression_Meter_Reset_Mode.GetIndex() == 0 && TimeSales[TSIndex].Price != LastBidTradePrice) Sellers_Meter = 0;
        Sellers_Meter += TimeSales[TSIndex].Volume;

        if (TimeSales[TSIndex].Price != LastBidTradePrice) {
          p_RecentBidAbsToBeErased[(int)(LastBidTradePrice / sc.TickSize) - ArrayPriceDifference] = 1;
        }

        p_BidCumulativeAbsorptions[TnsLoopArrayIndex] += TimeSales[TSIndex].Volume;
        p_BidTotalAbsorptions[TnsLoopArrayIndex] += TimeSales[TSIndex].Volume;      

        LastBidTradePrice = TimeSales[TSIndex].Price;
      }
    }
  } // End of TnS Iteration

[2017-11-12 20:15:55]
Sierra Chart Engineering - Posts: 104368
First of all, we are not sure how you have come to this conclusion. But it is likely the conclusion is wrong due to the nature memory corruptions.

And if it is correct, therefore there is some problem with that code and you need to resolve it. We do not provide programming help.

If you can provide us a complete study function which consistently reproduces the issue, we will test it and see if the problem is within Sierra Chart itself.
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
Date Time Of Last Edit: 2017-11-12 20:16:26
[2017-11-12 20:44:07]
Zosimus - Posts: 345
Yes I understand. The reason I thought the cause of the cpu exception errors was in this portion of the code is that when I excluded this portion the cpu exceptions stopped but obviously things can be more complex than this.
I only bothered you with this because the study works fine with Rithmic, CQG and TransAct feeds.
I understand that you can't help me with this and I certailny dont expect you to waste any more time on this.

Attached is the full study function I should be grateful if you could test if the problem is within Sierra Chart itself.

Many Thanks.
Date Time Of Last Edit: 2017-11-12 20:49:14
attachmentCPU_Exception_Test.cpp - Attached On 2017-11-12 20:43:22 UTC - Size: 101.16 KB - 564 views
[2017-11-13 19:54:13]
Sierra Chart Engineering - Posts: 104368
We quickly tested this and did not encounter any problems but that is a very complex study that also involves the use of memory allocations and pointers. You really are going to have to determine what the problem is.

We also did not see anything displayed on the chart after adding study to the chart.

We did test using CTS.

Also see if setting SC.FreeDLL = 0 changes anything.
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
[2017-11-13 23:11:43]
Zosimus - Posts: 345
Yes it's the most complex study I created so far (surely would have been much more elegant and efficient had I been a more proffessional programmer).

Anyway, many thanks for your time and patience. I will let you know if I manage to solve the problem with the code.
[2017-11-13 23:28:59]
Zosimus - Posts: 345
...and btw probably the study didn't do anything on your side because it needs a DOM with Recent Bid/Ask and Pulling/Stacking columns in the same chartbook.

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

Login

Login Page - Create Account