Export technical indicators to CSV

Posted By: Yop127

Export technical indicators to CSV - 07/12/18 19:55

Hello all,
I am trying to do something extremely simple: create a CSV with Date, open, high, low, close, RSI columns. However, I am new to Zorro, and cannot quite manage it.
Here is what I have currently:

function run()
{
set(LOGFILE|PLOTNOW);
NumYears = 1;

vars Prices = series(price());
vars Closes = series(priceClose());


vars Price = series(price());
vars Closes = series(priceClose());
file_append("C:JC.csv",RSI(Closes,3,2,100));
}


This does not work. Any help would be deeply appreciated!
Thanks in advance
Posted By: jcl

Re: Export technical indicators to CSV - 07/13/18 09:29

This does indeed not work. The simplest way is print(TO_CSV,...) with a format string and all variables that you want to export.
Posted By: Yop127

Re: Export technical indicators to CSV - 07/13/18 15:46

In case someone else has the same issue, this piece of code does the trick.

Code:
function run()
{
	StartDate = 20100101;
	BarPeriod = 1440;

  vars Close = series(priceClose());
  vars SMA100 = series(SMA(Close,100));
  vars SMA30 = series(SMA(Close,30));

  
  string Format = "n%04i-%02i-%02i %02i:%02i, %.10f, %.10f";
	
	
file_append("JC2.csv",strf(Format,year(),month(),day(),hour(),minute(), Close[0], SMA30[0]));

© 2024 lite-C Forums