2 registered members (rki, AndrewAMD),
407
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: get string from R
[Re: AndrewAMD]
#478328
10/03/19 21:37
10/03/19 21:37
|
Joined: Jul 2019
Posts: 26
maxwellreturn
OP
Newbie
|
OP
Newbie
Joined: Jul 2019
Posts: 26
|
In R, save strings to a file. Read the file from Zorro. thank you andrew, can you post an example of how i can store a string like this "EUR/USD,GBP/USD,EUR/JPY" from an external csv in a zorro string variable? thank you so much
|
|
|
Re: get string from R
[Re: maxwellreturn]
#478363
10/09/19 12:47
10/09/19 12:47
|
Joined: Jul 2019
Posts: 26
maxwellreturn
OP
Newbie
|
OP
Newbie
Joined: Jul 2019
Posts: 26
|
thank you andrew, i ve tried to do what you suggest, but i think i get a bug. this is mycode:
NumYears = 10;
BarPeriod = 60;
MaxLong = MaxShort = 1;
LookBack = 500;
asset(file_content("C:\\Users\\utente\\Zorro\\Data\\best1.csv"));
vars Price = series(priceClose());
int per = 100;
var x = 2.5;
vars Trends1 = series(SMA(Price,per));
vars Trends2 = series(SMA(Price,per*x));
if(crossOver(Trends1,Trends2))
enterLong();
if(crossUnder(Trends1,Trends2))
enterShort();
in the "best1.csv" there is only a line with written "GBP/AUD". And i get this error: Error 055: "GBP/AUD" no history (2010 History\ "GBPAUD" , t6) Error055: no bars generated
its like if it cant read the "/" in the file. Can someone explain why i get this wrong output? Ps: i ve got the t6 file 2010 of GBP/AUD
Last edited by maxwellreturn; 10/09/19 12:48.
|
|
|
Re: get string from R
[Re: AndrewAMD]
#478367
10/09/19 14:10
10/09/19 14:10
|
Joined: Jul 2019
Posts: 26
maxwellreturn
OP
Newbie
|
OP
Newbie
Joined: Jul 2019
Posts: 26
|
function run()
{
NumYears = 10;
BarPeriod = 60;
MaxLong = MaxShort = 1;
LookBack = 500;
asset(file_content("C:\\Users\\utente\\Zorro\\Data\\best1.csv"));
vars Price = series(priceClose());
int per = 100;
var x = 2.5;
vars Trends1 = series(SMA(Price,per));
vars Trends2 = series(SMA(Price,per*x));
if(crossOver(Trends1,Trends2))
enterLong();
if(crossUnder(Trends1,Trends2))
enterShort();
}
this is the entire code this is what i get, you can see error message in zorro and other file you see is the csv file. I tried even without the "" but it give me the same error. [img] https://ibb.co/5jQPxBt[/img]
|
|
|
Re: get string from R
[Re: maxwellreturn]
#478368
10/09/19 14:15
10/09/19 14:15
|
Joined: Jul 2019
Posts: 26
maxwellreturn
OP
Newbie
|
OP
Newbie
Joined: Jul 2019
Posts: 26
|
https://ibb.co/VHzkyDkthis is my history folder with the history of EUR/TRY (i said GBP/USD in the first post but i was wrong) can be something relative to the name of t6 files? or is it a bug?
|
|
|
Re: get string from R
[Re: maxwellreturn]
#478369
10/09/19 15:36
10/09/19 15:36
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
I bet your csv file uses quote characters! You cannot have any of that. Your file must be perfect. Your file contents must be exactly seven characters: GBP/AUD No quotes, no commas, no newline characters. It must be pure. If you right-click on the file and click Properties, the file size must be seven bytes. From R, one very good way to write the file would be to use the sink() method: https://stackoverflow.com/a/2471806
|
|
|
|