Gamestudio Links
Zorro Links
Newest Posts
Accessing All Historical Price Data
by JohnJits. 10/22/19 22:37
file_write var array ?
by laz. 10/22/19 16:00
SAV_STATS
by MatPed. 10/22/19 13:57
Instrument Price Zorro Chart
by jcl. 10/22/19 10:39
Calculating with price series
by AndrewAMD. 10/21/19 14:31
Error E355: Startup failure
by Dooley. 10/21/19 06:47
Today real live account blown - my experience
by Clifford_B. 10/19/19 17:09
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
4 registered members (JohnJits, AndrewAMD, Clifford_B, 1 invisible), 627 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
VillageTalkies, line7, Shutch, Clifford_B, Paulius
18310 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Plotting multiple assets #477839
08/02/19 16:54
08/02/19 16:54
Joined: Oct 2018
Posts: 65
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 65
AZ
I'm trying to look at how currency pairs move together. Is there an example of how to plot multiple assets on a single chart? I couldn't find plotting multiple assets in the manual. I am able to get multiple indicators for the same asset to plot by adding another plot call but I can't figure out how to adjust the code to get multiple assets plotted.

The code below plots a chart based on the drop down selected in the panel. If I change the panel dropdown, I get a different chart, which is neat but I'd like to get them all on one chart for visual comparison.

Code
function run() 
{
	set(LOGFILE);
	set(PLOTNOW);
	BarPeriod = 60*24;
	assetList("AssetsFix.csv");
	
	vars Prices = series(price());
	var RSI_plot = RSI(Prices,14);
	
	plot("Plot_RSI", RSI_plot, LINE, BLUE);
	 
}


I think I could probably get it to work if I declared each asset, stored each pair in memory and then made len(assetList) calls to print but that seems overly verbose.

The manual mentions looping through the asset list with while(asset(loop(Assets))). Would the plot call need to happen outside this loop? My guess is yes. How can I print all of these assets if I don't have them stored in memory?

Re: Plotting multiple assets [Re: chsmac85] #477841
08/02/19 17:51
08/02/19 17:51
Joined: Oct 2018
Posts: 65
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 65
AZ
As expected, if I manually write out the assets, I can get them to plot on the same chart.

Code
	asset("EUR/USD");
	vars Prices1 = series(price());
	var RSI_plot1 = RSI(Prices1,14);
	
	asset("EUR/CAD");
	vars Prices2 = series(price());
	var RSI_plot2 = RSI(Prices2,14);
	plot("EUR_RSI", RSI_plot1, LINE, RED);
	plot("EUR_RSI2", RSI_plot2, LINE, BLUE);
}

Re: Plotting multiple assets [Re: chsmac85] #477842
08/02/19 21:24
08/02/19 21:24
Joined: Oct 2018
Posts: 65
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 65
AZ
I was able to get the chart that I wanted created but it took 150 lines of code to plot the big 28 pairs. Seems kind of silly

Last edited by chsmac85; 08/02/19 21:24.
Re: Plotting multiple assets [Re: chsmac85] #477894
08/12/19 17:03
08/12/19 17:03
Joined: May 2018
Posts: 68
S
SBGuy Offline
Junior Member
SBGuy  Offline
Junior Member
S

Joined: May 2018
Posts: 68
I had a similar desire a while back and gave up as it got too complicated to maintain.

See this thread, maybe that'll give you some ideas.

https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Main=57298&Number=473236#Post473236

Re: Plotting multiple assets [Re: chsmac85] #477908
08/13/19 15:26
08/13/19 15:26
Joined: Jul 2000
Posts: 27,033
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,033
Frankfurt
For plotting multiple assets, use the PL_ALL flag.

https://manual.zorro-project.com/plotmode.htm

Re: Plotting multiple assets [Re: chsmac85] #477917
08/14/19 01:38
08/14/19 01:38
Joined: Oct 2018
Posts: 65
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 65
AZ
I tried to adapt a previous answer and jcl's response.

Code
function run() 
{
	set(LOGFILE);
	set(PLOTNOW+PL_ALL);
	BarPeriod = 60*24;
	StartDate = 2019;
	assetList("AssetsFix.csv");
	
	
	int cnt=0;
	while(asset(loop(Assets))){
		 Prices[cnt]=series(price());
		 rsi[cnt]=series(RSI(Prices[cnt]));
		 cnt++;
		 }
	 
asset(Assets[0]);
PlotWidth = 600;
PlotHeight1 = 500;
PlotHeight2 = 500;
int i;

	for(i=0;i<cnt;i++){
		 plot(strf("rsi for %s",Assets[i]),smas[cnt],0,BLUE);
		 ...plot more stuff...
		 }
	 
	 
}


This doesn't work as I get an undeclared identifier error.

Additionally, it seems that the variable would not be available inside the second loop unless I am misunderstanding the scoping.


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1