Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
7 registered members (EternallyCurious, 7th_zorro, Ayumi, Quad, AndrewAMD, ricky_k, 1 invisible), 497 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Stupid question .. #439438
04/02/14 20:13
04/02/14 20:13
Joined: May 2013
Posts: 627
Bonn
Sundance Offline OP
User
Sundance  Offline OP
User

Joined: May 2013
Posts: 627
Bonn
After some month I'am trying to program a strategy on my own.

Within the run routine I want for debugging to printf a variable. But the only value I get is 0.000 .

I'am surely doing a stupid failure but after two days of searching I need help :-)


Here is a simple testcode:

// Simple Test to output a value

function run()
{
BarPeriod = 15;
LookBack = 150;
StartDate = 20130401;
EndDate = 20130531;
asset("EUR/USD");

vars Price = series(price());

printf("%.5f", Price[0]);
quit();
return;
}


The output is only 0.00000. Why can't I see the price value?


thanks in advance for answering blush

Sundance

Re: Stupid question .. [Re: Sundance] #439440
04/02/14 20:27
04/02/14 20:27
Joined: May 2013
Posts: 245
S
swingtraderkk Offline
Member
swingtraderkk  Offline
Member
S

Joined: May 2013
Posts: 245
Sundance,

Try removing the quit & return, I don't see a need for them. esp quit, rem it will execute on the first run (INITRUN) when indicators and prices are not loaded.

Also try

printf("\n%1.5f", Price[0]);

\n for new line so its readable, and I think you need the 1 for the digit before the decimal point.

Re: Stupid question .. [Re: swingtraderkk] #439450
04/03/14 05:48
04/03/14 05:48
Joined: May 2013
Posts: 627
Bonn
Sundance Offline OP
User
Sundance  Offline OP
User

Joined: May 2013
Posts: 627
Bonn
Hi SwinTraderkk,

thanks for the feedback. The quit and return are resulting from a msg command I used instead of the printf.
But even with this code I have no output. I can't believe that I'am stuck at such a simple point.


// Simple Test to output a value

function run()
{
BarPeriod = 15;
LookBack = 150;
StartDate = 20130401;
EndDate = 20130531;
asset("EUR/USD");

vars Price = series(price());

printf("%1.5f\n", Price[0]);
}

Re: Stupid question .. [Re: Sundance] #439451
04/03/14 06:26
04/03/14 06:26
Joined: Jun 2013
Posts: 108
Alberta, Canada
C
CanadianDavid Offline
Member
CanadianDavid  Offline
Member
C

Joined: Jun 2013
Posts: 108
Alberta, Canada
I know this forum isn't Lite-C, but check the format string of the printf; is Price[0] really a float?

Re: Stupid question .. [Re: CanadianDavid] #439452
04/03/14 07:02
04/03/14 07:02
Joined: May 2013
Posts: 627
Bonn
Sundance Offline OP
User
Sundance  Offline OP
User

Joined: May 2013
Posts: 627
Bonn
I read the manual and it says that Price is a VARS (var*) and to output I do %f.
But I will try another values. I know that I had such a problem in the past and it was of the wrong usage of printf. :-)

I think I have a deep misunderstanding. I get no output at all. Shouldn't I see current price line after line?
This is from the manual:

"%[flags][width][.precision]f" for var or double variables with decimals.



Last edited by Sundance; 04/03/14 08:22.
Re: Stupid question .. [Re: Sundance] #439458
04/03/14 08:34
04/03/14 08:34
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
It's no misunderstanding, but just 2 different mistakes:

In the first script you get no output because you've quit the script before even loading price history, which happens after the first run.

In the second script you get no output because "\n" is like a carriage return on a typewriter: It jumps back to the begin of the line. For starting at a new line, you must place the "\n" _before_ and not after the rest of the line.

Re: Stupid question .. [Re: jcl] #439462
04/03/14 09:07
04/03/14 09:07
Joined: May 2013
Posts: 627
Bonn
Sundance Offline OP
User
Sundance  Offline OP
User

Joined: May 2013
Posts: 627
Bonn
Hi jcl,

man what a mess. I never had read that thingy about the \n. Thanks. Now I've got the output! :-)

The manual clearly states this:

For printing on a new line in the message window, begin the text with the linefeed symbol "\n". Otherwise printf appends the text to the end of the current line.

So I haven't read the manual good enough. My fault. I programmed in other C languages and there you can set the \n at the end of the line...

Re: Stupid question .. [Re: Sundance] #439466
04/03/14 10:18
04/03/14 10:18
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Yes, what the "\n" does depends on the implementation. When writing to a printer or in a file, "\n" at the end is perfectly fine - something that's already written won't get erased. This is different for Zorro's message window that behaves like a text terminal.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1