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 (AndrewAMD, Imhotep), 567 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
Print price not correct #474000
09/06/18 21:10
09/06/18 21:10
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Hi all,

why this print for the value Close and Open is always 0.0000
what am I doing wrong?

Code:
while(asset(loop(Assets)))
{
string CurrentAsset = Asset;
vars C = series(priceClose(0)); 
vars O = series(priceOpen(0));

print(TO_WINDOW,"n Asset = %s, C = %f, O = %f", CurrentAsset,C,O);


Re: Print price not correct [Re: tradingest] #474001
09/06/18 21:30
09/06/18 21:30
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
You can't print a vars. You can print an element of a vars, which is a var. C[0] is a var, for example.

Re: Print price not correct [Re: AndrewAMD] #474006
09/07/18 06:51
09/07/18 06:51
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Originally Posted By: AndrewAMD
You can't print a vars. You can print an element of a vars, which is a var. C[0] is a var, for example.


The correct code is
var C = series(priceClose(0));
var O = series(priceOpen(0));

Right?

Is necessary to calculate series for each asset takes into loop right?

Re: Print price not correct [Re: tradingest] #474007
09/07/18 06:53
09/07/18 06:53
Joined: Feb 2017
Posts: 369
D
Dalla Offline
Senior Member
Dalla  Offline
Senior Member
D

Joined: Feb 2017
Posts: 369
Yes, the price series must be inside the asset loop as in your first example.
Also the declaration string CurrentAsset = Asset; is redundant.
The Asset variable already holds the current Asset, so no need to also define CurrentAsset

Re: Print price not correct [Re: Dalla] #474008
09/07/18 10:24
09/07/18 10:24
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Originally Posted By: Dalla
Yes, the price series must be inside the asset loop as in your first example.
Also the declaration string CurrentAsset = Asset; is redundant.
The Asset variable already holds the current Asset, so no need to also define CurrentAsset


But I can write this code?

Code:
while(asset(loop(Assets)))
{
string CurrentAsset = Asset;
var C = priceClose(0); 
var O = priceOpen(0);



I must use necessary series or I can use the code above in this answer?

Re: Print price not correct [Re: tradingest] #474009
09/07/18 12:54
09/07/18 12:54
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
There is no need to declare CurrentAsset if Asset is always the current asset. Asset is a string, so you can use it in your printf function.

var C = series(priceClose(0)) is wrong because series() is a vars.

var C = priceClose(0) is correct because priceClose(0) is a var.

Finally, do not be afraid to experiment with coding. Try a code, see if it works, and if not, find out why. Master your craft. laugh

Re: Print price not correct [Re: AndrewAMD] #474011
09/07/18 14:17
09/07/18 14:17
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Hi Andrew,

my question was different.
I ask if necessary use the series to use close < High for instance or is necessary only price close and price high

Thank for your help

Re: Print price not correct [Re: tradingest] #474013
09/07/18 14:56
09/07/18 14:56
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
If this is the full scope of your code, you have no need for series.

Certain indicators will need series. But you're not using indicators.

You need to learn when and why to use a series. This is a fundamental lesson one learns from the Zorro tutorial - highly recommended.

Re: Print price not correct [Re: AndrewAMD] #474016
09/07/18 21:46
09/07/18 21:46
Joined: Feb 2018
Posts: 236
Italy
tradingest Offline OP
Member
tradingest  Offline OP
Member

Joined: Feb 2018
Posts: 236
Italy
Originally Posted By: AndrewAMD
If this is the full scope of your code, you have no need for series.

Certain indicators will need series. But you're not using indicators.

You need to learn when and why to use a series. This is a fundamental lesson one learns from the Zorro tutorial - highly recommended.


Thanks Andrew, your answer are very precious


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