|
Re: Strange error messages in for-loops
[Re: YesNotes]
#487338
03/20/23 16:21
03/20/23 16:21
|
Joined: Feb 2017
Posts: 1,650 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,650
Chicago
|
Thanks a lot, Andrew ! So do I get this right, that I should write:
int i = 0; and then simply for( i < period; i++) ? Yes. And is there a way to get notify of the replies here by mail? I nearly missed yours. I don't know. I just lurk here a lot.
|
|
|
Re: Strange error messages in for-loops
[Re: YesNotes]
#487341
03/21/23 12:54
03/21/23 12:54
|
Joined: Feb 2017
Posts: 1,650 Chicago
AndrewAMD
Serious User
|
Serious User
Joined: Feb 2017
Posts: 1,650
Chicago
|
Those are MT4/MT5 functions and values. This is Zorro, not MT4/MT5. You need to read the Zorro manual to see what functions, and variables are available. Read these: https://zorro-project.com/manual/en/month.htmhttps://zorro-project.com/manual/en/date.htm (check out the Now variable, which is an input, not an output) Also, when Zorro outputs errors, you should read the errors, comprehend the errors, and revise your code based on what the errors say. If you must share your problems here, disclose the errors and your code for best results. https://zorro-project.com/manual/en/trouble.htm
|
|
|
Re: Strange error messages in for-loops
[Re: YesNotes]
#487347
03/21/23 20:24
03/21/23 20:24
|
Joined: Mar 2023
Posts: 14 Freiburg
YesNotes
OP
Newbie
|
OP
Newbie
Joined: Mar 2023
Posts: 14
Freiburg
|
Thank you Andrew, you are exceptionally helpful! the thing is that I did not dare to push my script onto anyone< so I only gave you the line the error code did mention. But since you asked; here is my script, and the syntax error in line 15 mentioned is: for (int year = StartDate; year <= EndDate; year++) Note that the error is actually not in that line but the opening bracket is supposed to be line 15 I don't see any syntax error. Can you point me to my error? function run()
{
StartDate = 2015;
EndDate = 2022;
BarPeriod = 1;
LookBack = 1440;
PlotScale = 15;
Commission = 0.6;
Spread = 0.3*PIP;
int start_time = 90009;
int end_time = 100110;
for (int year = StartDate; year <= EndDate; year++)
{ // <-- THIS IS ERROR LINE 15 !
for (int week = 1; week <= 52; week++)
{
var time = 0;
for (int day = 1; day <= 7; day++)
{
time = weekday(timeFromWeeks(year, week, day));
if (time == MONDAY)
{
for (int hour = 9; hour <= 10; hour++)
{
for (int minute = 0; minute <= 1; minute++)
{
for (int second = 9; second <= 10; second++)
{
var bar_time = timeHour(time) * 10000 + timeMinute(time) * 100 + timeSecond(time);
if (bar_time >= start_time && bar_time <= end_time)
{
// Do comparison here
// Example: var close = priceClose(0);
// var open = priceOpen(0);
// if (close > open) { /* do something */ }
}
time = (time + 60); // Advance to next minute
}
}
}
}
}
}
}
}
If you wonder what this script is about: It simply is a test whether I can compare two trading cycles from different times.
Last edited by YesNotes; 03/21/23 20:30. Reason: I tried to keep the script format
|
|
|
Re: Strange error messages in for-loops
[Re: AndrewAMD]
#487370
03/24/23 12:20
03/24/23 12:20
|
Joined: Mar 2023
Posts: 14 Freiburg
YesNotes
OP
Newbie
|
OP
Newbie
Joined: Mar 2023
Posts: 14
Freiburg
|
Thank you, Andrew. I tried for days now to declare the variables right and always seem to have made it wrong, so I wrote the most simple script possible to figure out first only how to declare variables. It simply shows the date and time. // Declare variables
int year = 2022;
int month = 3;
int day = 23;
int hour = 15;
int minute = 30;
int second = 0;
// Create datetime object
datetime myDateTime = date(year, month, day) + time(hour, minute, second);
// Print datetime object
printf("My date and time: %s", strdate(myDateTime));
Zorro 2.53.9 does throw, however following error: Error in 'line 11: syntax error < datetime myDateTime = date(myYear, myMonth, myDay) + time((int)myHour, (int)myMinute, (int)mySecond); >. Can you tell me what I am doing wrong?
Last edited by YesNotes; 03/24/23 12:20.
|
|
|
|