Advertisement
Guest User

Untitled

a guest
May 26th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.61 KB | None | 0 0
  1. //Export selected asset history to CSV
  2.  
  3. function run()
  4. {
  5.     History=".t1";
  6.     set(TICKS);
  7.     BarPeriod = 0.1/60;
  8.     LookBack = 0;
  9.     StartDate = 20080101;
  10.     EndDate = 20080201;
  11.    
  12.     asset("NZDUSDs");
  13.  
  14.     string Format = ifelse(assetType(Asset) == FOREX,
  15.         "\n%04i-%02i-%02i %02i:%02i:%.3f, %.5f",
  16.         "\n%04i-%02i-%02i %02i:%02i,%.3f %.1f");
  17.     char FileName[40];
  18.     sprintf(FileName,"History\\%s.csv",strx(Asset,"/","")); // remove slash from forex pairs
  19.    
  20.     if(is(INITRUN))
  21.         file_write(FileName,"Date,Price",0);
  22.     else
  23.         file_append(FileName,strf(Format,
  24.             year(),month(),day(),hour(),minute(),second(),
  25.             price()));
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement