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
5 registered members (TipmyPip, AndrewAMD, Quad, aliswee, degenerate_762), 970 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
Going crazy - maybe for the while loop? #471336
02/28/18 13:17
02/28/18 13:17
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Hello, I´m coding a simple strategy, beginner (very) and I get stuck every step I take (no matter I want to learn). I spent 2 hours or more yestrerday with this simple code:

Code:
// MINUTE TRADES TEST //

void run()
{
  vars Open = series(priceOpen());
  vars High = series(priceHigh());
  vars Low = series(priceLow());
  vars Close = series(priceClose());
  BarPeriod = 1;
  LookBack = 5;
  StartDate = 20170601;
  EndDate = 20170831;
  
  int opentime=08; //0800
  int closingtime=23; //2300

  // OPEN LONG CODITIONS AND CLOSE IF SEEMS TO GO BAD
if ((!TradeIsOpen) and (tod(0)>=opentime) and (tod(0)<=closingtime)){
  if (Close[1]<Close[0])
		{	 
		enterLong();
		} }
	 
while(TradeIsLong){
		if ((Close [1]> Close[0])  or (tod(0)>=closingtime))
	  {	 
     exitLong();
	  }}

  // OPEN SHORT CODITIONS AND CLOSE IF SEEMS TO GO BAD	  
if ((!TradeIsOpen) and (tod(0)>=opentime) and (tod(0)<=closingtime)) {
  if (Close[1]>Close[0])
			{	
			enterShort();
			}}
	 
while(TradeIsShort){
	if ((Close[1]<Close[0]) or (tod(0)>=closingtime))
	  {	 
     exitShort();
	  } }
	  
}




I just wanted to test my skills and I crashed. If I code a simple short term (minutes) strategy like this one, Why does Zorro keep compiling until I get tired and finally have to kill the process?

Is there a problem in MY "while" loop? Maybe I misundestood the "while" condition.

Any help? Thank you.

tomas

Re: Going crazy - maybe for the while loop? [Re: tomaslolo] #471337
02/28/18 13:48
02/28/18 13:48
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
You want "if" instead of "while" there. The whole run() function normally is repeated every minute with new prices. If you put a while with a condition that is always satisfied, it will get stuck there forever and nothing gets repeated.

Last edited by Hredot; 02/28/18 13:49.
Re: Going crazy - maybe for the while loop? [Re: Hredot] #471362
03/01/18 08:22
03/01/18 08:22
Joined: Feb 2018
Posts: 68
T
tomaslolo Offline OP
Junior Member
tomaslolo  Offline OP
Junior Member
T

Joined: Feb 2018
Posts: 68
Thank you very much for your help.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1