Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,484 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Hello and creating a displaydebugmsg function #425087
06/26/13 14:32
06/26/13 14:32
Joined: Jun 2013
Posts: 41
Ohio, USA
P
Pork Offline OP
Newbie
Pork  Offline OP
Newbie
P

Joined: Jun 2013
Posts: 41
Ohio, USA
Hello,
My first post using Zorro S 1.10 to create my first script.
My experience includes many years of programming in many different languages some very similar to, but not c++.
So below is my programming exercise.
Just an exercise no trading involved, yet.
The purpose of the script is to create an oscillator and display it. Note: that it is not complete and does NOT work properly. It is definitely a work in progress.
During the writing I discovered the debug method and included it. Then I thought, "can't this be used as a function to be called from many areas of a script?".
So I created a function passed the variables I wanted and displayed the message. and what I get is in the attached .jpg file.
What is happening is the message is getting passed , but the msg( command is not interpreting it as an instruction, but the message box just displays the message string as passed, including the quotes and the Yes or No.
If I select no it will stop the script just like it is supposed to. The text displayed in the box is not correct. If someone will kindly explain how to include a jpeg in line of the message that would be helpful also.
The code is included below. Not quite sure what to make of this. Helpful suggestions are being accepted.
Thanks
P

static int prevosc = 50;//first osc value should be 50 after we use the previous value
static int debug = 1;//for debugging change to 0 to stop
static int goon = 0;//for debug messages
static string quote = "\"";

function Displaydebugmsg (string message1, string message2)
{
char message[80];
strcpy(message,quote);
strcat(message, message1);
strcat(message, quote);
strcat(message, message2);
goon = msg(message);
if(goon == 0) {
quit();
}

}

function Oscar()
{
//this function will determine the Osc value for current pair
//it is for the 15 min chart and displays on a page of it's own.
//the formulas for OSC is:
//A= Highest High for last 8 periods
//B= Lowest Low of last 8 periods
//D= last closing price
//X= previous Oscillator value init to 50
// formula is ((x/3)*2 + ((d-b/a-b)*100)/3)

vars H = series(priceHigh(),8),
L = series(priceLow(),8),
C = series(priceClose());


double A = H[0];
double B = L[0];
double D = C[0];


double oscarvalue =((prevosc / 3)*2) + ((D - B / A - B) * 100) / 3;

if(debug ) {
string messp1 = "P = %i H = %.5f L = %.5f C = %.5f oscarvalue = %.3i";
string messp2 = ",prevosc,A,B,D,oscarvalue";
Displaydebugmsg (messp1, messp2);
}


//use oscarvalue for next computation
prevosc = oscarvalue;
return(oscarvalue);
}

function run()
{

BarPeriod = 15;

int Osc = Oscar();

}

Attached Files
zmsg.jpg (4 downloads)
Re: Hello and creating a displaydebugmsg function [Re: Pork] #425088
06/26/13 14:51
06/26/13 14:51
Joined: Jul 2000
Posts: 28,024
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,024
Frankfurt
What you need is the sprintf function: http://manual.zorro-trader.com/str_.htm

You then generate a display string like this:

...
char message[80];
sprintf(message, "P = %i H = %.5f L = %.5f C = %.5f oscarvalue = %.3i",prevosc,A,B,D,oscarvalue);
goon = msg(message);
...

Note that you have to pass the variables to the function, otherwise there's nothing to display. Thus, writing a "general" displaydebugmsg function won't work this way because you need to tell the function somehow which variables you want to see.

Re: Hello and creating a displaydebugmsg function [Re: jcl] #425090
06/26/13 15:08
06/26/13 15:08
Joined: Jun 2013
Posts: 41
Ohio, USA
P
Pork Offline OP
Newbie
Pork  Offline OP
Newbie
P

Joined: Jun 2013
Posts: 41
Ohio, USA
Thanks jcl, I'll give it a try.
P
edit: that did thanks again!!!!

Last edited by Pork; 06/26/13 15:20.

Moderated by  Petra 

Gamestudio download | 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