Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, SBGuy, Petra, flink, 1 invisible), 699 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
plot multiple assets #467915
09/07/17 17:15
09/07/17 17:15
Joined: Aug 2017
Posts: 3
F
fz5 Offline OP
Guest
fz5  Offline OP
Guest
F

Joined: Aug 2017
Posts: 3

// plot price series for each asset in a separate chart

function run()
{
BarPeriod = 1440;
NumYears = 1;

int N=0;
while(asset(loop("AUD/USD","EUR/USD","GBP/USD"))) {
vars Price = series(price());
plot(strf("price_%i",N), Price, NEW, BLACK);
N++;
}
}

Re: plot multiple assets [Re: fz5] #467916
09/07/17 17:22
09/07/17 17:22
Joined: Aug 2017
Posts: 3
F
fz5 Offline OP
Guest
fz5  Offline OP
Guest
F

Joined: Aug 2017
Posts: 3
Sorry, I submitted the above code accidentally before I typed my question. I'm testing the simple code to plot the price series for each asset in a separate chart. Somehow it only plots for the first asset. Can anyone point out what's wrong with the code? Thanks a lot!

Re: plot multiple assets [Re: fz5] #467919
09/07/17 20:42
09/07/17 20:42
Joined: Feb 2017
Posts: 1,725
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,725
Chicago
Probably because you're sending "plot" inside the asset loop.

This works, though.
Code:
// plot price series for each asset in a separate chart 

function run()
{
    set(PLOTNOW);

    BarPeriod = 1440;	
    NumYears = 1;

    vars Price[3];
    int N=0;
    string names[3];
    while(asset(loop("AUD/USD","EUR/USD","GBP/USD"))) 
    {	
        names[N] = Asset;
        Price[N] = series(price());	
        N++;	
    }

    for(N=0; N<3; N++)
    {
        plot(strf("price_%s",names[N]), Price[N], NEW, BLACK);
    }

}


Re: plot multiple assets [Re: AndrewAMD] #467921
09/07/17 21:21
09/07/17 21:21
Joined: Aug 2017
Posts: 3
F
fz5 Offline OP
Guest
fz5  Offline OP
Guest
F

Joined: Aug 2017
Posts: 3
That works! Thank you very much!


Moderated by  Petra 

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