Login Page - Create Account

Support Board


Date/Time: Sat, 04 Jan 2025 08:02:32 +0000



Post From: sc.StorageBlock limitations

[2016-05-20 00:22:07]
User754985 - Posts: 109
sc.StorageBlock is said to be of 512b.

Yet, I cannot fit all of the following variables into it:

struct s_PermData
  {
    int ChartPosition;
    double Lastentryprice; //or reduced to float
    int Lastentrybar;
    
    int LastIntOrderId;
    int LastPTargetOrderId;
    int LastSLOrderId;
    
  };
s_PermData* PermData;
PermData = (s_PermData*)sc.StorageBlock;

in the beginning of my code I retrieve these values and at the end- save into sc.StorageBlock.

CurrentPosition=PermData->ChartPosition;  
        
      if (CurrentPosition==0)
      {
        entrybar=i;
        entryprice=(double)sc.Close[i];
        TargetOrderID=0;
        StopOrderID=0;
        IntOrderID=0;
      }
      else
      {
        entrybar=PermData->Lastentrybar;
        entryprice=PermData->Lastentryprice;
        IntOrderID=PermData->LastIntOrderId;
        TargetOrderID=PermData->LastPTargetOrderId;
        StopOrderID=PermData->LastSLOrderId;
      }

....................................
...................................

PermData->ChartPosition=CurrentPosition;  
      PermData->Lastentryprice=entryprice;
      PermData->Lastentrybar=entrybar;
      PermData->LastIntOrderId=IntOrderID;
      PermData->LastPTargetOrderId=TargetOrderID;
      PermData->LastSLOrderId=StopOrderID;[/i]

A double and 1 int - work. 5 ints - work. A float and 2 ints - work...All of them together - generate a CPU exception at runtime.

Why would this be?

Is there a way to define a second StorageBlock for the study instance?