Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Imhotep, opm), 785 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
get string from R #478315
09/30/19 18:27
09/30/19 18:27
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
hi guys,
is there a way to get a string value from R? i tried every function like "ri" "rd" and "rv" with a character array but nothing appened.
I have to get an asset name from the Rterm.

Thanks, have a nice day

Re: get string from R [Re: maxwellreturn] #478316
09/30/19 18:38
09/30/19 18:38
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
In R, save strings to a file. Read the file from Zorro.

Re: get string from R [Re: AndrewAMD] #478328
10/03/19 21:37
10/03/19 21:37
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
Originally Posted by AndrewAMD
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] #478333
10/04/19 14:11
10/04/19 14:11
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
There are many R samples on the internet, and Zorro is very well-documented. Why not give it a try? laugh

If you want to make it easy, forget CSV's. Just put a single string in a temp file and load one at a time.
https://zorro-project.com/manual/en/str_.htm
https://zorro-project.com/manual/en/file_.htm

Re: get string from R [Re: maxwellreturn] #478363
10/09/19 12:47
10/09/19 12:47
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

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:
Code
        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:
Quote

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: maxwellreturn] #478364
10/09/19 13:13
10/09/19 13:13
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Zorro eliminates the slash intentionally for things such as filenames, like t6 files. After all, you cannot have a slash in a filename.

I see no problems with this snippet. If you're still confused, post your entire script. It's more likely there's a problem with your history setup.

Re: get string from R [Re: AndrewAMD] #478367
10/09/19 14:10
10/09/19 14:10
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
Code
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
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
https://ibb.co/VHzkyDk
this 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,718
Chicago
AndrewAMD Offline
Serious User
AndrewAMD  Offline
Serious User

Joined: Feb 2017
Posts: 1,718
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

Re: get string from R [Re: maxwellreturn] #478372
10/09/19 17:11
10/09/19 17:11
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
wow thank you so much man, you were right the file was with quote characacters and it was 9 bytes. With sink function in R i get 7 bytes file thank you so much.

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1