How to get the value of e.g. price and CCI - page 2

 

Thanks onewithzachy,

I have tried to follow the thread + i have set the 'Max bars in chart' to 99999999999999 and as you say now it now shows me 2147483647, but it still doesn't work.

My broker is FXDD, but i have to try it on another broker to see if it works there.

 

:D I think you just post on the wrong thread there. Please delete that post, it may confuse people, and I won't reply there too.

I haven't fully check everything coz I'm doing something else too. I add a little debug to the script and it create debug file with no problem. I think the reason your script does not create a file because the extern value of "to Date" and the "from date" that you set. Why don't you check that again, coz you know that better than us.

And one more thing, even though we set max bar to unlimited on chart, not all bars/candles are loaded into chart. To solve this problem open a chart, then press and hold "Page Up" key (thanks to RaptorUK) or"Home" key and look at chart Time on the bottom of the chart. Press and hold this "page up/Home" key as long as you need until you think all the needed bars are loaded into a chart.

:D

//+------------------------------------------------------------------+
#property copyright "Forex Script"
#property link      "http://www.xyz.com"

#include <stdlib.mqh>

// external variables
extern bool   showArrows= true;
extern string fromDate="2011.1.1";
extern string toDate="2011.12.31";
extern bool   Print_Debug=False;

// local variables
int    xCountBars=0;
double BodySize=3;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int init()
  {
   ObjectsDeleteAll();      // clear the chart
   Comment("");    // clear the chart
  }
//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//----
   PlaySound("wait.wav");
   int FileHandle;
   FileHandle = FileOpen(Symbol()+"_CCI.csv", FILE_CSV|FILE_WRITE,',');      
   if(FileHandle < 1)                                                    
     {
      string txt = "Creation of "+Symbol()+"_CCI.csv failed. Error #"+ErrorDescription(GetLastError());
      Alert (txt);
      //Print (txt);
      return(0);
     }
     
   if(Print_Debug == true) 
     {
     
     Print ("Bar 0 time ",TimeToStr (Time[0], TIME_DATE)," Bar ",Bars-1," time ",TimeToStr (Time[Bars - 1], TIME_DATE));
     Print ("");
     int File_Debug ;
     File_Debug = FileOpen(Symbol()+"_CCI_Debug.txt", FILE_CSV|FILE_WRITE,','); 
      
     if(File_Debug < 1)                                                    
        {
        txt = "Creation of Debug "+Symbol()+"_CCI_Debug.txt failed. Error #"+ErrorDescription(GetLastError());
        Alert (txt);
        //Print (txt);
        return(0);
        }
     FileWrite(File_Debug,StringConcatenate("Bar 0 time ",TimeToStr (Time[0], TIME_DATE),
               " Bar ",Bars-1," time ",TimeToStr (Time[Bars - 1], TIME_DATE))); // File HEADER
     }
     
   FileWrite(FileHandle,"DATE","HOUR","MIN","PRICE","CCI");  // File HEADER

   int ix;
   for(ix=4; ix<Bars; ix++)
     {
      if(ix>2999) Print("ix = ",ix," Bars = ",Bars," Time ix ",TimeToStr(Time[ix]));
      
      // Get CCI value
      double xCCI = iCCI(NULL,NULL,14,PRICE_CLOSE,ix); 
      
      if (Print_Debug == true)
         {
         FileWrite(File_Debug,TimeToStr(Time[ix],TIME_DATE),StringSubstr(TimeToStr(Time[ix],TIME_MINUTES),0,2),
                    StringSubstr(TimeToStr(Time[ix],TIME_MINUTES),3,2),Close[ix],xCCI);   
         }
         
      if(Time[ix] < StrToTime(fromDate) || Time[ix] > StrToTime(toDate)) //"2011.1.1" == 2011.12.31"
         {
         /*
         txt = TimeToStr (Time [ix],TIME_DATE);
         if(Time[ix] < StrToTime(fromDate) && Print_Debug) 
            Print ("Time ix ",txt," is < than from date ",fromDate," no file write.");
         if(Time[ix] > StrToTime(toDate) && Print_Debug) 
            Print ("Time ix ",txt," is > than to Date ",toDate," no file write.");
          */ 
         continue;
         }
      
      FileWrite(FileHandle,TimeToStr(Time[ix],TIME_DATE),StringSubstr(TimeToStr(Time[ix],TIME_MINUTES),0,2),
                StringSubstr(TimeToStr(Time[ix],TIME_MINUTES),3,2),Close[ix],xCCI);

     } // For loop

   // Close file
   FileClose(FileHandle);
   if (File_Debug > 0) FileClose(File_Debug);
   PlaySound("wait.wav");
   return(0);
  }
//+------------------------------------------------------------------+
 
onewithzachy:

:D I think you just post on the wrong thread there. Please delete that post, it may confuse people, and I won't reply there too.

I haven't fully check everything coz I'm doing something else too. I add a little debug to the script and it create debug file with no problem. I think the reason your script does not create a file because the extern value of "to Date" and the "from date" that you set. Why don't you check that again, coz you know that better than us.

And one more thing, even though we set max bar to unlimited on chart, not all bars/candles are loaded into chart. To solve this problem open a chart, then press and hold "Page Up" key (thanks to RaptorUK) or"Home" key and look at chart Time on the bottom of the chart. Press and hold this "page up/Home" key as long as you need until you think all the needed bars are loaded into a chart.

:D


Thanks onewithzachy, post deleted! :D

Ok i wil try to take a look at it and see if it will work out for me.

I'll let you know.
Reason: