Gamestudio Links
Zorro Links
Newest Posts
folder management functions
by 7th_zorro. 04/16/24 13:19
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
LPDIRECT3DCUBETEXTUR
E9

by Ayumi. 04/12/24 11:00
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 04/11/24 14:56
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (rki, Ayumi), 475 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
11honza11, ccorrea, sakolin, rajesh7827, juergen_wue
19045 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Zorro vs TradeStation - Trade entry #476436
02/26/19 00:35
02/26/19 00:35
Joined: Mar 2017
Posts: 65
G
Ger1 Offline OP
Junior Member
Ger1  Offline OP
Junior Member
G

Joined: Mar 2017
Posts: 65
Has anyone tried matching Zorro backtest results with TradeStation's?

I am trying to match trade results of a daily SPY ETF trading strategy between Zorro and TradeStation. The SPY trades from 9:30 - 16:00 Eastern Time. I have used TradeStation's historical data for this backtest.

Within TradeStation trades can be entered at the current bar at close or the next bar at the open. In Zorro trades are usually entered at the close or at the next bar's open (by setting Fill to 3).
However, by setting Fill to 3 all trades are entered at the next bar's open. Is there a way to specify this for each trade individually? (e.g. enter long trades at the next bar's open and exit them at the current bar's close).


Also, for setting up bars I have used following settings:

StartMarket=930;
EndMarket=1600;
BarPeriod=6.5*60;
StartWeek=11200;
EndWeek=52100;
BarZone=ET;
Weekend=18;

The created bars are similar to TradeStation's but especially the open differs (it's frequently the same as the previous close, which is incorrect).

Re: Zorro vs TradeStation - Trade entry [Re: Ger1] #476437
02/26/19 07:04
02/26/19 07:04
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Depends on the historical EOD data I think. If open and previous close are the same price then the data is either wrong or they were really the same at that day.

Re: Zorro vs TradeStation - Trade entry [Re: Petra] #476439
02/26/19 11:57
02/26/19 11:57
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
Zorro's concept of a "bar" is that of a "time period". The end time of one is the start of another,and therefore - be definition (and Zorro's enforcement of this)- the close of a bar is the open of the next bar, regardless of what happens in between or during the period.

This is different to how TS/MC and several other platforms define bars, restricting them to "sessions" and actual trading activity/prices.

Variables like StartMarket, etc are just "convenience flags" that mostly do not influence "bar" creation.

Main differences to TS in bars will be observed between sessions and over-the-weekend when Zorro will cover such periods with some bars, depending on Weekend and BarZone settings (the consequence being that most range and moving average calculations will be different to TS).

You will be able to replicate results of a TS system by manually constructing TimeFrames. Work through the examples in the manual and search forum for my posts on this.

Studying how Weekend/BarZone/StartEndMarket/StartEndWeek/AssetMarket and TimeFrame/framesync/frameOffset/frame() create bars and frames under different settings/combinations of settings would help a lot.

Good luck!

Re: Zorro vs TradeStation - Trade entry [Re: Zheka] #476441
02/26/19 13:37
02/26/19 13:37
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
I think the issue was the open and close price, no "time period".

Re: Zorro vs TradeStation - Trade entry [Re: Petra] #476445
02/26/19 16:53
02/26/19 16:53
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
Quote:
but especially the open differs (it's frequently the same as the previous close, which is incorrect).
This is a consequence of how differently TS/MC and Zorro construct 'bars', not data per se
(which - I infer - are data exported from TS)

Re: Zorro vs TradeStation - Trade entry [Re: Zheka] #476447
02/26/19 22:22
02/26/19 22:22
Joined: Mar 2017
Posts: 65
G
Ger1 Offline OP
Junior Member
Ger1  Offline OP
Junior Member
G

Joined: Mar 2017
Posts: 65
Thanks for your comments guys.

That's exactly what I was thinking. I was hoping that there would be a simple way around this but your comments seem to confirm that there is not.

FYI, I have got 1 minute price data from TS. I have experimented quite a bit with Weekend/BarZone/StartEndMarket/StartEndWeek/AssetMarket and TimeFrame/framesync/frameOffset/frame() to create bars and frames but could not replicate TradeStation's bars.

Also by creating custom bars and frames there's always the issue that the open equals the previous close. This is a huge problem when trying to code gap strategies, entering at the next bar's open or current close or coding patterns (e.g. Close(1)>Open(1), which in Zorro more or less means Close(1)>Close(2)).

Would you be able to provide a code example for mimicking TS's bars?


Or indicate how it could work?
Would creating 2 different frames, one for the open and one for the close solve it?

Re: Zorro vs TradeStation - Trade entry [Re: Ger1] #476448
02/27/19 07:28
02/27/19 07:28
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
I dont know, but to mimick TS daily bars, cant you export the bars directly? 1 minute price data is very different to daily bars and the close is then of course often the same as next open, because the difference is only 1 tick. And if 1 minute price data has no gaps then zorro bars also have no gaps.

So better import the same daily bars as in TS, and set Fill = 3 for entering at next open and then Fill = 1 for exiting at the today close. But if you really use 1 minute bars in your strategy, then you can simply compare the time and enter and exit at the market open and close time.

Re: Zorro vs TradeStation - Trade entry [Re: Petra] #476449
02/27/19 12:32
02/27/19 12:32
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
Using pre-built daily bars might work.

If not, then use the TimeFrame variable over granular BarPeriod(1-5min) to construct the "Daily" bars which would start and end as you require (skip overnights).
Setting TimeFrame to a negative number specifies how many bars back it covers and ends the frame.

Have you seen sample code for this is on the TimeFrame page in the manual?

Re: Zorro vs TradeStation - Trade entry [Re: Zheka] #476460
03/02/19 01:07
03/02/19 01:07
Joined: Mar 2017
Posts: 65
G
Ger1 Offline OP
Junior Member
Ger1  Offline OP
Junior Member
G

Joined: Mar 2017
Posts: 65
Thanks a lot for your inputs.

I'd love to user higher resolution than daily bars, however using daily bars is a pretty good idea and at least for daily bars I have been able to replicate it in Zorro.

TradeStation usually displays bars in the user's local time or exchange time, so I first had to convert the closing time to 0:00 UTC. After that I converted the TS csv file to t6. Using Weekend = 0 and leaving leaving BarOffset and BarZone at its default did the trick for mimicking TS's bars.


I haven't realised that Fill can be changed several times within the script. This worked!

For now I left Slippage and commission at 0. I tested a simple mean reverting SPY strategy from 2010 till today with more than 200 trades.

Surprisingly TS and Zorro's trade results matched on the cent!

I tested several combinations such as entering at this close and exiting at the next bar's open, etc. and all of them matched.


TradeStation's buy() this bar at close is identical to Fill = 0 (or 1); enterLong();

TradeStation's sell() next bar at open is identical to Fill = 3; exitLong();



Regarding TimeFrame, I experimented quite a lot but still haven't been able to get it working. Basically it's always the same issue in that the current open is equal to the previous close even when there is a gap in-between.

Would you suggest using two different frames, one for the open and one for the close?

Re: Zorro vs TradeStation - Trade entry [Re: Ger1] #476463
03/02/19 09:04
03/02/19 09:04
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Why frames? When you have higher resolution bars, like 30 min, you can simply enter the trade at 15:30 and close it at 9:30.


Moderated by  Petra 

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