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
1 registered members (AndrewAMD), 552 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
EXITRUN only in simulations? #473336
06/29/18 15:21
06/29/18 15:21
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Trying to collect some information while trading and saving them after finishing the strategy, mostly done by pressing the Stop button. I thought this could be done in a for(all_trades) loop in EXITRUN but surprisingly this does not work.
Quote:
EXITRUN
Last run of the simulation. All trades are closed. [...]

Really only in simulations? Is there any function to use in live trading?

Re: EXITRUN only in simulations? [Re: Sphin] #473341
06/30/18 01:52
06/30/18 01:52
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
If you know how long trading sessions take, you could use dataNew, dataAppendRow, dataSet and e.g. in half an hour intervals dataSave. Then roughly note the session start time and make sure to hit Stop only after the last half an hour has been dumped.

Re: EXITRUN only in simulations? [Re: Hredot] #473345
06/30/18 11:21
06/30/18 11:21
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Thanks, but the for(all_trades) loop itself is okay, my intention was more finding a trigger to execute it if trading of the strategy is stopped.

Re: EXITRUN only in simulations? [Re: Sphin] #473349
06/30/18 12:17
06/30/18 12:17
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
I see, here is a hacky way:

Code:
...
if(file_date("your\path\stop.txt")>0){
    ... save data here ...
}
...



Create stop.txt shortly before stopping the script, and delete it right after.

Re: EXITRUN only in simulations? [Re: Hredot] #473351
06/30/18 16:35
06/30/18 16:35
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Quick and dirty, I use a lot of such solutions!

Quote:
Create stop.txt shortly before stopping the script, and delete it right after.

Hmm ... but instead of creating the stop.txt shortly before stopping the script I could also execute the for(all_trades) loop - if I only knew when the time is "shortly before stopping the script" but this is the time in question.

Re: EXITRUN only in simulations? [Re: Sphin] #473352
06/30/18 17:26
06/30/18 17:26
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
Simplest solution would be of course, if you know exactly how long and at what hours of day the trading session starts and ends. Then you could execute the for(all_trades) loop e.g. exactly at market close time and just make sure to hit Stop a minute or two later.

Re: EXITRUN only in simulations? [Re: Hredot] #473353
06/30/18 18:50
06/30/18 18:50
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Simplest solution would be an 'onStop event handler' or making EXITRUN available also in trade mode. The evaluate (PERFORMANCE* perf) would be a possible workaround but in trade mode it is executed when the status page is updated, only in test mode at the end of a test or when Result is clicked. An onResultClick event in trade mode was also a viable way ...

Re: EXITRUN only in simulations? [Re: Sphin] #473355
06/30/18 19:12
06/30/18 19:12
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
I agree, ideally they should implement this in Zorro so people don't have to do ritual dances around it to get it to work.

Re: EXITRUN only in simulations? [Re: Hredot] #473360
07/01/18 13:33
07/01/18 13:33
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
I hope they dont, because when I hit stop I want it to stop, not to start another run. There must be a better solution.

Re: EXITRUN only in simulations? [Re: Petra] #473361
07/01/18 13:44
07/01/18 13:44
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Why start another run? if(is(EXITRUN)) is a trigger to execute some commands after the simulation. My intention is to make it or any substitute available not only in test but also in trade mode. It has nothing to do with restarting the run.

Re: EXITRUN only in simulations? [Re: Sphin] #473362
07/01/18 14:10
07/01/18 14:10
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
No, Exitrun is a flag that is set when Zorro starts its last run:

http://manual.zorro-project.com/is.htm

When you hit stop you want no exit run. Imagine the script places wrong trades or the market crashes, so you hit stop, then you dont want it to continue for another run.

Re: EXITRUN only in simulations? [Re: Petra] #473363
07/01/18 14:56
07/01/18 14:56
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Originally Posted By: Petra
I hope they dont, because when I hit stop I want it to stop, not to start another run. There must be a better solution.


Hi Petra,
Can you explain why having a function activated pressing the STOP button pressed should be a bad thing?
I do not get it. Thank You

Re: EXITRUN only in simulations? [Re: MatPed] #473365
07/01/18 15:39
07/01/18 15:39
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
You think its no bad thing when Stop starts another run with possibly new trades? You must be very rich! laugh laugh

Re: EXITRUN only in simulations? [Re: Petra] #473366
07/01/18 15:47
07/01/18 15:47
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
EXITRUN should be special, where only functions wrapped in if(is(EXITRUN)){...} get executed. There, problem solved.

Re: EXITRUN only in simulations? [Re: Petra] #473367
07/01/18 16:06
07/01/18 16:06
Joined: Feb 2015
Posts: 652
Milano, Italy
M
MatPed Offline
User
MatPed  Offline
User
M

Joined: Feb 2015
Posts: 652
Milano, Italy
Originally Posted By: Petra
You think its no bad thing when Stop starts another run with possibly new trades? You must be very rich! laugh laugh


that's not an answer. If you have a function you can use it well, wrong or do not use it at all.

Re: EXITRUN only in simulations? [Re: MatPed] #473368
07/01/18 16:59
07/01/18 16:59
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
To give an example, what I'm doing is simply:
Code:
if(is(EXITRUN)) 		
  	for(all_trades) 
  		print(TO_CSV, "%s, %s, %.1f, %.2fn", strdate("%y%m%d %H:%M:%S", TradeEnterTime), Asset, SpecialKey, TradeProfit);


Means after the last run Zorro prints to CSV each trade together with a special key number (TradeVar). No restart of run or what ever, only printing trade results to CSV.

Or like MatPed said: you are not forced to use this function.

Re: EXITRUN only in simulations? [Re: Sphin] #473373
07/01/18 22:34
07/01/18 22:34
Joined: Sep 2003
Posts: 929
Spirit Offline

Moderator
Spirit  Offline

Moderator

Joined: Sep 2003
Posts: 929
I think the chance of such a "feature" is zero, because it would be not backwards compatible and users would not expect that a button named "stop" starts a new run. Why not using simply the evaluate or cleanup function?

Re: EXITRUN only in simulations? [Re: Spirit] #473391
07/02/18 16:01
07/02/18 16:01
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Quote:
users would not expect that a button named "stop" starts a new run

No one would expect it, me neither.

Quote:
Why not using simply the evaluate or cleanup function?

With pleasure. Could you please give me a hint how to call a function after the end of trading the with the evaluate function?

Quote:
From the manual:
For globally allocated memory areas, define a void cleanup() function that releases memory. The function will be automatically called at end or termination of the session.

Does this work:
Code:
void cleanup() {
   for(all_trades) 
  	print(TO_CSV, "%s, %s, %.1f, %.2fn", strdate("%y%m%d %H:%M:%S", TradeEnterTime), Asset, SpecialKey, TradeProfit);
}


Re: EXITRUN only in simulations? [Re: Sphin] #473413
07/03/18 16:23
07/03/18 16:23
Joined: Dec 2013
Posts: 568
Fuerth, DE
Sphin Offline OP
User
Sphin  Offline OP
User

Joined: Dec 2013
Posts: 568
Fuerth, DE
Amazing, with cleanup() at least a "hello-world-csv" is created when the stop button is hit. If the trade history is still present this moment I can indeed use it as a workaround for EXITRUN in trade mode.

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1