Assigning Values to Array

Back to topics list To post a new topic, please log in or register
avatar
4
tymoore510 2015.03.26 16:51
 

I have a simple formula that is calculating the FastK. I am using the ds array to allow me to access historical values as well. When I use the Print statement, it shows that it is calculating the formula properly, but it is not assigning the value to the specified array element. I have attached an image showing the output log. Anyone know why this would happen?

class FastK
{
public:
   // Variables
   int Length;
   double ds[];
   
   // Constructors   
   FastK(void){};
   FastK(int length)
   {
      Length=length;
      ArraySetAsSeries(ds,true);
   };  
   
   void Calculate(int shift)
   {
      int bar = Bars-IndicatorCounted();
      if (bar<Length)      
         return;  
         
      double lowest = Low[iLowest(NULL,0,MODE_LOW,Length,shift)];
      double highest = High[iHighest(NULL,0,MODE_HIGH,Length,shift)];
      double num = Close[shift]-lowest;
      double den = highest-lowest;            
      
      if (den!=0)
      {                  
         ds[shift]=num/den*100;
         Print("ds = ",ds[shift],", formula = ",num/den*100);
      }
      else      
         ds[shift]=0;   
   };
};

avatar
13006
WHRoeder 2015.03.26 20:03 #
 
DS has no size. You can't assign to it until you resize it.
avatar
4
tymoore510 2015.03.26 20:21 #
 
You are a gentleman and a scholar! I had a feeling I was overlooking the obvious. Thank you for your assistance.
Back to topics list  

To add comments, please log in or register