help me find out why array can't get value.

 
//+------------------------------------------------------------------+
//|                                                       MYNNEA.mq4 |
//|                       Copyright ?2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
/*
#import "ExpertSample2.dll"
   int    GetIntValue(int);
   double GetDoubleValue(double);
   string GetStringValue(string);
   double GetArrayItemValue(double arr[], int, int);
   bool   SetArrayItemValue(double& arr[], int,int, double);
   double GetRatesItemValue(double rates[][6], int, int, int);
   int    SortStringArray(string& arr[], int);
   int    ProcessStringArray(string& arr[], int);
   double  CalculatePossibility(int,int,double& x[][],int& y[]);
#import
*/
//---- input parameters
extern int       magic = 111111;




//---- globale variable


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----

     
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
datetime tmp;
double possibility;

int start()
  {
//----
   if(Bars<1000)
   {
   Print("we have no enough history data");
   return(0);
   }
   
   if(tmp!=Time[0])
   {
  double samples[1000][12];
  int   rs[1000];
  int counts=0;

    
         for(int i=1;i<Bars;i++)
         {
         int rstmp;
         if(i==1)
         rstmp=0;
         else
         rstmp = (Close[i-1]-Open[i-1])/Point;
        
               if(MathAbs(rstmp)>200||i==1)
                {
                rs[counts] = rstmp;  
     
                double max = MathMax(MathMax(High[i],High[i+1]),High[i+2]);
                double min = MathMin(MathMin(Low[i],Low[i+1]),Low[i+2]);
     
                samples[counts][0]=s(Close[i],min,max);
                samples[counts][1]=s(Open[i],min,max);
                samples[counts][2]=s(High[i],min,max);
                samples[counts][3]=s( Low[i],min,max);
                samples[counts][4]=s(Close[i+1],min,max);
                samples[counts][5]=s(Open[i+1],min,max);
                samples[counts][6]=s( High[i+1],min,max);
                samples[counts][7]=s( Low[i+1],min,max);
                samples[counts][8]=s(Close[i+2],min,max);
                samples[counts][9]=s( Open[i+2],min,max);
                samples[counts][10]=s( High[i+2],min,max);
                samples[counts][11]=s(Low[i+2],min,max);
                Print(counts);
                Print(samples[counts][0]);//here we can see that samples array has the values.
                counts = counts +1;
                if(counts ==1000)
                break;
                }
           }

  
         


      
       // possibility = CalculatePossibility(1000,12,samples,rs);
       
       
      double lots = MathAbs(NormalizeDouble(possibility,1));
         
          
           for(int p = 0;p<1000;p++)
            for(int pp =0;pp<1;pp++)
               Print(DoubleToStr(samples[p][pp],2));//why here the value it prited all equle 0,
         
  
         tmp = Time[0]; 
   }
          int cnt = OrdersTotal();
       int buy,sell;
       for(int l=0;l<cnt;l++)
       {
         if(OrderSelect(l,SELECT_BY_POS,MODE_TRADES))
            if(OrderMagicNumber()== magic)
               if(OrderType()==OP_BUY)
               { buy++;
               if(possibility<-0.5)
               OrderClose(OrderTicket(),OrderLots(),Bid,3,CLR_NONE);
               }
               else
               { sell++;
               if(possibility>0.5)
               OrderClose(OrderTicket(),OrderLots(),Ask,3,CLR_NONE);
               }
           else
           continue;
        
       }  
              
     
        
       if(buy==0 && possibility>0.5)
         OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,0,"mynn",magic,0,Green);
       if(sell ==0 && possibility <-0.5)
         OrderSend(Symbol(),OP_SELL,lots,Bid,3,0,0,"mynn",magic,0,Red);
         
       
   
//----
   return(0);
  }
//+------------------------------------------------------------------+


double s(double x,double min,double max)
{
   return((x-min)/(max-min));
}


i have write the problem in code comment. please take a look. thankyou.

 

Look carefully at this part of code

if(MathAbs(rstmp)>200||i==1)
                {
                rs[counts] = rstmp;  
     
                double max = MathMax(MathMax(High[i],High[i+1]),High[i+2]);
                double min = MathMin(MathMin(Low[i],Low[i+1]),Low[i+2]);
     
                samples[counts][0]=s(Close[i],min,max);
                samples[counts][1]=s(Open[i],min,max);
                samples[counts][2]=s(High[i],min,max);
                samples[counts][3]=s( Low[i],min,max);
                samples[counts][4]=s(Close[i+1],min,max);
                samples[counts][5]=s(Open[i+1],min,max);
                samples[counts][6]=s( High[i+1],min,max);
                samples[counts][7]=s( Low[i+1],min,max);
                samples[counts][8]=s(Close[i+2],min,max);
                samples[counts][9]=s( Open[i+2],min,max);
                samples[counts][10]=s( High[i+2],min,max);
                samples[counts][11]=s(Low[i+2],min,max);
                Print(counts);
                Print(samples[counts][0]);//here we can see that samples array has the values.
                counts = counts +1;
                if(counts ==1000)
                break;
                }
You fulfil it only one time when i==1.
 
Roger wrote >>

Look carefully at this part of code

You fulfil it only one time when i==1.

thank you.

i have found out the reason.

becasue i 'd like to get 1000 sample, but it can't . i change 1000 to 500, now it works.

roger do you know how to make sure we have a number of history data ?

 
Sorry, I didn't get you want to ask me.