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
3 registered members (VoroneTZ, monk12, Quad), 829 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
Plotting multiple assets #477839
08/02/19 16:54
08/02/19 16:54
Joined: Oct 2018
Posts: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
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: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
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: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
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: 134
S
SBGuy Offline
Member
SBGuy  Offline
Member
S

Joined: May 2018
Posts: 134
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,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
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: 70
AZ
C
chsmac85 Offline OP
Junior Member
chsmac85  Offline OP
Junior Member
C

Joined: Oct 2018
Posts: 70
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.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1