1 registered members (AndrewAMD),
552
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
EXITRUN only in simulations?
#473336
06/29/18 15:21
06/29/18 15:21
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
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. 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]
#473349
06/30/18 12:17
06/30/18 12:17
|
Joined: Sep 2017
Posts: 235
Hredot
Member
|
Member
Joined: Sep 2017
Posts: 235
|
I see, here is a hacky way:
...
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
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
Quick and dirty, I use a lot of such solutions! 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]
#473362
07/01/18 14:10
07/01/18 14:10
|
Joined: Apr 2008
Posts: 585 Austria
Petra
Support
|
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.htmWhen 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
MatPed
User
|
User
Joined: Feb 2015
Posts: 652
Milano, Italy
|
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]
#473368
07/01/18 16:59
07/01/18 16:59
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
To give an example, what I'm doing is simply:
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: Spirit]
#473391
07/02/18 16:01
07/02/18 16:01
|
Joined: Dec 2013
Posts: 568 Fuerth, DE
Sphin
OP
User
|
OP
User
Joined: Dec 2013
Posts: 568
Fuerth, DE
|
users would not expect that a button named "stop" starts a new run No one would expect it, me neither. 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? 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:
void cleanup() {
for(all_trades)
print(TO_CSV, "%s, %s, %.1f, %.2fn", strdate("%y%m%d %H:%M:%S", TradeEnterTime), Asset, SpecialKey, TradeProfit);
}
|
|
|
|