multiple results graph in multi-asset scripts?

Posted By: SBGuy

multiple results graph in multi-asset scripts? - 06/22/18 19:19

Is there a way to generate multiple result graphs/plots when in a multi-asset script?

My multi-asset script only plots the last asset.

Posted By: jcl

Re: multiple results graph in multi-asset scripts? - 07/02/18 09:55

Look for "PlotMode" in the manual, there you can set a multi-asset mode.
Posted By: SBGuy

Re: multiple results graph in multi-asset scripts? - 07/02/18 23:31

Doesn't quite do what I was hoping for. PlotMode PL_ALL just mashes the graphs together making them not legible. I was hoping for neat single asset result plot that I can use to analyze and debug.

Looks like I'll have to do one asset a time for this.

Thanks.
Posted By: Hredot

Re: multiple results graph in multi-asset scripts? - 07/03/18 02:32

If you have all the asset price curves and let's say SMAs saved in different globally defined series, there is nothing stopping you from doing something like

Code:
int cnt=0;
while(loop(Assets)){
    asset(Loop1);
    Prices[cnt]=series(price());
    smas[cnt]  =series(SMA(Prices[cnt],10));
    cnt++;
}
asset(Assets[0]);
PlotWidth = 600;
PlotHeight1 = 500;
PlotHeight2 = 500;
int i;
for(i=0;i<cnt;i++){
    plot(strf("%s",Assets[i]),Prices[cnt],NEW,BLACK);
    plot(strf("sma for %s",Assets[i]),smas[cnt],0,BLUE);
    ...plot more stuff...
}



to plot all of them in separate graphs.
Posted By: SBGuy

Re: multiple results graph in multi-asset scripts? - 07/03/18 17:39

I see. Thanks for the tip Hredot.
Posted By: AdamWu

Re: multiple results graph in multi-asset scripts? - 07/13/20 13:27

Hi Hredot, I am new to Zorro and I can not run your code. It complained about Prices and smas undefined and some other errors. So I canged the code to:
Code
function run() 
{
	StartDate = 20200710; 
	// My Assets File
	assetList("AssetsFXCMLite");
	int cnt=0;
	vars Prices[10];
	vars smas[10];
	BarPeriod = 1440;
	while(loop(Assets)){
		//printf("\n%s", Loop1);
		//asset(Loop1);
		Prices[cnt] = series(priceClose());
		smas[cnt] = series(SMA(Prices[cnt],10));
		cnt++;
	}
	asset(Assets[0]);
	PlotWidth = 600;
	PlotHeight1 = 500;
	PlotHeight2 = 500;
	int i;
	print("\n*************** %d",cnt);
	for(i=0;i<cnt;i++){
		plot(strf("%s",Assets[i]),Prices[i],NEW,BLACK);
		plot(strf("sma for %s",Assets[i]),smas[i],0,BLUE);
	}
}


Now there is no errors. But the plots are the same. (See bellow). Can you give me a clue?
[Linked Image]
Posted By: AdamWu

Re: multiple results graph in multi-asset scripts? - 07/13/20 13:28

Originally Posted by SBGuy
I see. Thanks for the tip Hredot.

Can I have look of your code, thansks.
Posted By: AdamWu

Re: multiple results graph in multi-asset scripts? - 07/13/20 14:53

Never mind I find a way to do so:
Code
vars Prices[3];
vars smas[3];
function run() 
{
	StartDate = 20200710; 
	// My Assets File
	assetList("AssetsFXCMLite");
	int cnt=0;
	BarPeriod = 1440;
	while(loop(Assets)){
		asset(Loop1);
		Prices[cnt] = series(priceClose());
		smas[cnt] = series(SMA(Prices[cnt],10));
		cnt++;
	}
	asset(Assets[0]);
	PlotWidth = 600;
	PlotHeight1 = 500;
	PlotHeight2 = 500;
	int i;
	for(i=0;i<cnt;i++){
		plot(strf("%s",Assets[i]),Prices[i],NEW,BLACK);
		plot(strf("sma for %s",Assets[i]),smas[i],0,BLUE);
	}
}
Posted By: Enivant

Re: multiple results graph in multi-asset scripts? - 04/14/23 10:16

Only cleaned up your code, it works fine (unfortunately it seems to not be possible to plot candles in all charts: "Candles and bands are only plotted in the main chart."
see https://zorro-project.com/manual/en/plot.htm)):

Code


Code
vars Prices[0];
vars smas[0];

function run()
{
	set(PLOTNOW);
	PlotWidth = 600;
	PlotHeight1 = 500;
	PlotHeight2 = 500;
	StartDate = 20220101;
	EndDate = 20220205;
	BarPeriod = 1440;
	//My Asset File
	assetList("AssetsXY"); 

	int cnt = 0;
	int i;


	//while(loop(Assets))
	while(asset(loop(Assets)))
	{
			Prices[cnt] = series(priceClose());
			smas[cnt] = series(SMA(Prices[cnt],10));
			cnt++;
	}

	asset(Assets[0]);

	for(i=0;i<cnt;i++)
	{
			plot(strf("Cl for %s",Assets[i]),Prices[i],NEW,BLACK);
			plot(strf("SMA for %s",Assets[i]),smas[i],0,BLUE);
	}
	
}




Attached picture PlotStock_multiassets_SPY.png
© 2024 lite-C Forums