Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by 3run. 02/28/20 09:28
Editting
by peterhw. 02/27/20 15:20
PS1 texturing bubbling ?
by 3run. 02/27/20 13:36
enum case / if else
by danatrader. 02/27/20 00:07
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
11 registered members (3run, Jerome8911, AndrewAMD, alibaba, txesmi, Sinuhet, Quad, FLD, Dalla, jenGs), 968 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Emrah06, zac, DebraSteed, Ricard, Apollo1
18379 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,118
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,118
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,118
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,118
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.


Powered by UBB.threads™ PHP Forum Software 7.7.1