Login Page - Create Account

Support Board


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



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

[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