export asset to .txt file

Posted By: tuuPaul

export asset to .txt file - 05/15/19 01:28

Hello all, Is it possible to export assets(USDJPY, EURUSD, CADJPY...etc) to .txt file using zorro script? if it is possible give me some advice. To export assets to .txt file manually is needs more time.
Posted By: tuuPaul

Re: export asset to .txt file - 05/15/19 04:47

Also it needs to automatically export assets in time frequency
Posted By: Petra

Re: export asset to .txt file - 05/15/19 05:36

There is a command print(TO_CSV...) for this.
Posted By: tuuPaul

Re: export asset to .txt file - 05/15/19 09:29

is it really true?
Posted By: AndrewAMD

Re: export asset to .txt file - 05/15/19 09:54

Yes.
Posted By: tuuPaul

Re: export asset to .txt file - 05/15/19 12:06

this script works but in file-export_USDJPY.csv there is no price only many string of 'une'. How to get price value?

function run(){
StartDate = 20160101;
EndDate = 20161231;
TimeFrame = 1;
vars une = series(priceClose());
print(TO_CSV,"une",une);
plot("une",une,NEW,BLUE);
}
Posted By: SBGuy

Re: export asset to .txt file - 05/15/19 15:35

Dude... it's:

print(TO_CSV,"%f",une[0])

It adds a new CSV line at every run()

You can't just print a vars variable directly.
Posted By: tuuPaul

Re: export asset to .txt file - 05/15/19 16:02

Also i want to print dates with time. This price is timeframe of 1hour time. How?
Posted By: SBGuy

Re: export asset to .txt file - 05/15/19 16:51

One of these functions should get what you want.

https://zorro-project.com/manual/en/month.htm

Off the top of my head, this will probably work

wdateBar(Bar)

play around with them.
Posted By: tuuPaul

Re: export asset to .txt file - 05/16/19 02:24

i tried to rewrite under your advice. Script is below but there is an error not work. What is the problem?

function run()
{
asset("EUR/JPY");
StartDate = 20160101;
EndDate = 20161231;
TimeFrame = 1;
vars une = series(priceClose());
printf(TO_CSV,"nDate: %s",strdate(YMDH,0));
print(TO_CSV,"une=%.3f",une[0])
}
Posted By: tuuPaul

Re: export asset to .txt file - 05/16/19 04:44

First row in .csv file is 0 price. I don not understand it.
Posted By: Spirit

Re: export asset to .txt file - 05/16/19 06:55

You must enter first the start and end dates and then the asset and not the other way around. Thd error messages are all explained in the manual.
Posted By: tuuPaul

Re: export asset to .txt file - 05/16/19 07:01

i followed your instruction but there is nothing change.
Posted By: sdh309795gaas

Re: export asset to .txt file - 05/17/19 14:21

I would do it like this:

Code:
WriteFormat = "n%.5f,%.5f,%.5f,%.5f,%.5f,%.5f,%.5f,%.5f"
//this needs to match your variables!
//each %.5f means a var with 5 Digits, %d would mean an integer

sprintf(FileName,"Data\blabla%s.csv",strx(Asset,"/","")); // remove slash from forex pairs

if(is(INITRUN)
{
file_delete(FileName); //if you want to delete old files
file_write(FileName,"this,that,somethingelse,....",0);    //Header
}
file_append(FileName,strf(WriteFormat,v1,v2,v3...);
//v1, v2 are the variables you want to write

© 2019 lite-C Forums