HELP WITH DOWNLOAD DATA STOCHASTIC

Back to topics list To post a new topic, please log in or register
avatar
45
burnssss 2014.01.28 21:16
 
Very good,

as I can modify this code so that only data download me a week ago?

//+------------------------------------------------------------------+
//|                                               output_history.mq4 |
//+------------------------------------------------------------------+


//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
int start()
  {
//  out_hist("GBPUSD",PERIOD_D1);  // This will produce daily history for GBPUSD
  out_hist(Symbol(),Period());
// Copy the above line of code for each currency pair and timeframe, and then press F5 to recompile (or restart MT4)
// First parameter must be a valid currency pair, e.g. GBPUSD, enclosed in double quotes
// Second parameter must be valid timeframe, i.e. one of PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1
// To use the currently displayed chart: out_hist(Symbol(),Period());

  return(0);
  }

//+------------------------------------------------------------------+
//| Main history output engine                                       |
//+------------------------------------------------------------------+
int out_hist(string ccy, int tf)
{
//  int    digits    = MarketInfo(ccy,MODE_DIGITS);
//  string OHLCmask  = "TR3." + NumberToStr(digits,"1");
  string fname = ccy + "," + tf + ".csv";                         // Same folder (...\experts\files) for each timeframe
//string fname = "TF-" + tf + "\\" + ccy + "," + tf + ".csv";     // Different subfolder for each timeframe
  int handle = FileOpen(fname, FILE_CSV|FILE_WRITE, ",");         // "," means that output data will be separated by commas; change if necessary
  if(handle>0)
    {
     FileWrite(handle,"Date,Time,Open,High,Low,Close,Volume, Stochastic");    // This writes the Header record to the file (change or remove to suit)
//   for(int i=0; i<iBars(ccy,tf); i++)                           // Use descending date sequence
     for(int i=iBars(ccy,tf)-1; i>=0; i--)                        // Use ascending date sequence
       {
       string date1 = TimeToStr(iTime(ccy,tf,i),TIME_DATE);
       date1 = StringSubstr(date1,5,2) + "-" + StringSubstr(date1,8,2) + "-" + StringSubstr(date1,0,4);
// NOTE: StringSubstr(date1,5,2) is the MONTH
//       StringSubstr(date1,8,2) is the DAY
//       StringSubstr(date1,0,4) is the YEAR (4 digits)
//       "-" means the separator will be a hyphen
//       So if, for example, you want to change the output date format to DD/MM/YYYY, change the above line of code to:
//     date1 = StringSubstr(date1,8,2) + "/" + StringSubstr(date1,5,2) + "/" + StringSubstr(date1,0,4);

       string time1  = TimeToStr(iTime(ccy,tf,i),TIME_MINUTES);
       FileWrite(handle, date1, time1, iOpen(ccy,tf,i), iHigh(ccy,tf,i), iLow(ccy,tf,i), iClose(ccy,tf,i), iVolume(ccy,tf,i)
                  ,iStochastic(ccy,tf,80,1,1,MODE_SMA,0,MODE_MAIN,i)
                  ,iStochastic(ccy,tf,80,1,1,MODE_SMA,0,MODE_SIGNAL,i)); 
// The above line writes the data to the file in the order: date, time, open, low, high, close, volume. Change the order to suit, if necessary
// Or you can add indicator based outputs, e.g. iMA(); iRSI(); iMACD(); etc
// Examples:  iMACD(ccy,tf,12,26,9,PRICE_CLOSE,MODE_MAIN,i)
//            iADX(ccy,tf,14,PRICE_CLOSE,MODE_MAIN,i)
       }
     FileClose(handle);
     Comment("History output complete");     // Display a comment in the upper left corner of the chart to advise that process is complete
    }
   return(0);
  }
  
//+------------------------------------------------------------------+

Many thanks

avatar
12985
WHRoeder 2014.01.28 21:45 #
 
burnssss as I can modify this code so that only data download me a week ago?
  1. Where is your attempt? learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. Get last weeks datetime, get corresponding chart bar index. Loop starting from there.
avatar
4
StewartLCoad 2015.05.02 03:46 #
 
WHRoeder:
  1. Where is your attempt? learn to code it, or pay someone. We're not going to code it FOR you. We are willing to HELP you when you post your attempt (using SRC) and the nature of your problem.
  2. Get last weeks datetime, get corresponding chart bar index. Loop starting from there.

avatar
4
StewartLCoad 2015.05.02 03:50 #
 
Hello everyone.

I had this scripts working OK prior to build 600 but now I can't find the file it produces. I've looked through every folder in MetaTrader.

Can anyone point me in the right direction ?

Thank you in anticipation. 
avatar
12985
WHRoeder 2015.05.02 14:22 #
 
StewartLCoad:  I've looked through every folder in MetaTrader.
Data Structure in MetaTrader 4 Build 600 and Higher - MQL4 Articles 17.02.2014
Back to topics list  

To add comments, please log in or register