Gamestudio Links
Zorro Links
Newest Posts
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
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 (Quad, AndrewAMD), 410 guests, and 0 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
Page 1 of 2 1 2
Trading with Zorro - list of things to clarify #466841
07/04/17 16:11
07/04/17 16:11
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783

Hello,

Here are several things I would like to clarify about Zorro operation.

Testing
1. WFO: How does Zorro treat "transitional" trades from one OOS period to another and from IS(training) to OOS?

2. WFO: Is there a way to set Training/Testing periods in calendar terms (days, weeks or months) rather than bars?

3. How does "DETREND=TRADES" actually work?

4. How are Holidays' accounted for? Is there a way to filter out data based on certain country's holidays?


Live Trading
1. When does Zorro technically "close" a bar (say, m1)?
Does it happen "on-time" or upon arrival of the first/opening tick of a new bar (like in several other platforms)?

2. What prices are used during Live trading? Are bars built based on Ask? How to make it work based on mid-point?

3. What "order management" functions does Zorro have to
help handle possible "order placement" errors/ canceling orders/ syncing between Zorro and the broker?
I see there is a "NumRejected" variable.Is it updated real-time? Reasons for order rejection are only going to the log?

4. I guess there is no support for native OCO orders with IB? Or is it?

Thanks a lot for clarifications in advance!

Re: Trading with Zorro - list of things to clarify [Re: Zheka] #466849
07/04/17 17:36
07/04/17 17:36
Joined: Jun 2017
Posts: 78
B
BobbyT Offline
Junior Member
BobbyT  Offline
Junior Member
B

Joined: Jun 2017
Posts: 78
Hi Zheka,

I'm super noobish here but lets see if I can help with a couple of these.

Testing:
1) Not sure what you exactly mean but this graphic shows how WFO steps through the data: http://zorro-project.com/manual/

2) Couldn't you just use daily/weekly/monthly bars and restrict the trading period using full dates instead of just years (or add conditionals that limit trading based on dates if StartDate/EndDate do not take yyyy-mm-dd

3)My guess here is that price remains static and the time trades are placed are shuffled (with prices adjusted accordingly). So instead of making price random with DETREND=PRICES we make the trades random (I have a feeling I'm way off here but that is how I see it)

The rest...I have no idea.

Cheers,
BobbyT

Re: Trading with Zorro - list of things to clarify [Re: BobbyT] #466854
07/04/17 18:02
07/04/17 18:02
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
Some addendums:

In WFO training, there are no transitional trades. Open trades at the end of the period are ignored. In WFO testing, transitional trades can happen. The trade is then opened with parameters from period A and closed with parameters from period B.

For periods in days, just multiply the number of days by 1440/BarPeriod.

DETREND = TRADES corrects the result of any trade by the price difference that would result from detrending the prices.

Time periods with no trading are not included in historical data. For adding a holiday even when the market is open, you must let your script prevent trading on that day.

Bars are just time periods. Their start and end does not depend on price quotes.

All prices are used. The mid point is Price - 0.5*Spread.

The order management depends on the broker API implementation. Normally a trade is cancelled when it is not filled within a certain time period.

All order types are realized with market or limit orders. Special order types by the broker are normally not used.


Re: Trading with Zorro - list of things to clarify [Re: jcl] #466856
07/04/17 18:19
07/04/17 18:19
Joined: Jun 2017
Posts: 78
B
BobbyT Offline
Junior Member
BobbyT  Offline
Junior Member
B

Joined: Jun 2017
Posts: 78
Hi JCL,

Thanks for the clarifications. Good info to have laugh

Cheers,
BobbyT

Re: Trading with Zorro - list of things to clarify [Re: jcl] #466863
07/05/17 00:37
07/05/17 00:37
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Thank you, JCL.

Quote:
The trade is then opened with parameters from period A and closed with parameters from period B.


So, if the starting position in B should be short, will Zorro close the open long position from period A?

Quote:
For periods in days, just multiply the number of days by 1440/BarPeriod


A common scenario is to close positions end-of-day or end-of-week. And therefore a WFO cycle is naturally linked to "sessions" rather than bars. And sessions can be quite different across assets.
But the main problem is holidays and early closes. What would you recommend?
I believe adding a "calendar" way to specify periods (across Zorro) would simplify life in many use cases.

Quote:
All prices are used. The mid point is Price - 0.5*Spread.

How to correctly program to accept a bid in Real-Time to calculate spread (in case of IB)?
Or spread calculation in RT happens automatically regardless of pre-set spread amount?
Can one just use a t8 contract structure for Forex?

Quote:
The order management depends on the broker API implementation.

How developed is it for IB plug-in?
How can one programmatically handle order rejection?
Get broker order ID -is it TradeID in TMF? applicable to IB? Cancel an order?

Quote:
Normally a trade is cancelled when it is not filled within a certain time period.

Does this also pertain to a limit order? What would this "period" be for IB Plugin?

Quote:
TMF return values:
1 - if the trade is still open or pending, exit it now.

If the "trade is pending" - can mean a rejected/pending market order?
"Exit now" a pending "buy@limit " - means cancel a limit order?

Quote:
2 - if the trade is still pending, enter it now.

Does it mean that a pending limit/stop order is converted to market order?

What's the way to obtain an order fill price (from the broker)?
(especially in the case of stop orders which can execute intrabar). Having a TMF function execute on every tick is inefficient if the whole strategy evaluates on a timeframe.



Last edited by Zheka; 07/05/17 00:38.
Re: Trading with Zorro - list of things to clarify [Re: Zheka] #466867
07/05/17 07:41
07/05/17 07:41
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
If opposite positions are closed or not depends on your script. WFO cycles should not be linked to seasons. Otherwise you'll get artifacts when the market is season dependent. Market data variables, like spread, swaps, fill prices etc. reflect the market in real time. What to do in case of order rejection is up to your script. The default order fill time is 30 seconds if I remember right, and also applies to limit orders. "Pending" means that the trade is not yet opened, not that it is rejected. Pending trades and limit orders are two different things. A pending trade is no order, it only sends an order when the price hits the entry limit.

You can find all the basic details about trades, stops, etc. on these pages:

http://manual.zorro-project.com/buylong.htm
http://manual.zorro-project.com/stop.htm
http://manual.zorro-project.com/trade.htm

and in the examples in the tutorial. If then something is still unclear or not covered by the manual, just ask here.

Re: Trading with Zorro - list of things to clarify [Re: jcl] #466919
07/07/17 16:17
07/07/17 16:17
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
1.
Quote:
WFO cycles should not be linked to seasons. Otherwise you'll get artifacts when the market is season dependent

I meant "sessions", not seasons. I have extensive experience with WFO and can think of no artifacts caused by defining WFO cycles in calendar days/weeks (but can readily see them with bar-defined WFO cycles for any strategy adapting parameters via optimization).

I do believe that adding a "calendar" way to specify periods is necessary, but if not now, then how would you suggest handling holidays and early closes?

Also, do I understand correctly, that "1440" should really be the actual number of minutes in a trading day?

2.
Quote:
Market data variables, like spread, swaps, fill prices etc. reflect the market in real time.


Sorry, the whole process is not clear from the documentation.
Specifically, in the case of IB:
- is "spread" variable updated in RT automatically?
- are the "fill" prices actual or reflect "Ask" at the time of order execution?

- What is the "Trade ID" number? Is this for MT4? IB operates with OrderIDs..
- How is Profit and Profit in Pips calculated in Trade Statistics (they cannot be retrieved from IB API)?
- Is Profit in Pips actual or calculated off some earlier set quote currency rate?
- Does PIPCOST update itself in RT (with IB)?
- will TradeProfit in Trade struct be actual fill-based or "price (ask/bid) at the time of entry order submission?

3.
Quote:
Pending trades and limit orders are two different things. A pending trade is no order, it only sends an order when the price hits the entry limit.

I now better understand trade placement mechanism used by Zorro by default.
So, to place a limit order, one needs to use ORDERLIMIT flag.

Questions (in the context of IB ):
- when is a limit order actually sent to the market?
IS it sent when the Entry function is processed or when price hits the limit in RT?
- if not, How to send it with Entry? (which has the advantage of getting earlier in to the order queue).

- when modifying a limit order price with ExitLong/Short, does ORDERLIMIT cancels and resubmits an order or just modifies a price?
- how to cancel an order in the script?

4.
Quote:
What to do in case of order rejection is up to your script


To decide what to do, i need to get the reason for order rejection. How to? What functions are used for that?

E.g. If there is not enough margin when trading a portfolio, I would prefer to reduce size rather than miss the trade (skipped trade would impact all equity curve related calculations, incl. optF). Multicharts does such pre-trade size checking and adjustments automatically.

5.
Quote:
TMF return values:
1 - if the trade is still open or pending, exit it now.
2 - if the trade is still pending, enter it now


Means a market order will be sent immediately for a pending limit entry/exit?


6. What order fill assumptions are used for "entry at limit"/"exit at stop" orders in simulation?
Will they fill when:
- price touches the level at least 1 time?
- price penetrates the level by xx ticks?
- M1 close price touches/penetrates the order level?

7.using LEAN and M1:
- when LEAN is NOT set, is the Open/Close price of a bar=Open/Close price of the first/last M1 tick?

8. If a price history is in M1 "ticks", will the TMF functions/Stops/limits in RT also evaluate in 1-min ticks or on each and every real RT tick?

9. Is it possible in Zorro to receive data from a datafeed while placing orders with a broker?

10. Millisecond Timestamps: is there a way to see exact timings of order sending and filling (to monitor latency/slippage)?

Re: Trading with Zorro - list of things to clarify [Re: Zheka] #466953
07/10/17 15:44
07/10/17 15:44
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
You can see why adapting WFO cycles to seasons is no good idea when you imagine the consequences of some examples - like a WFO training cycle of 4 calendar days followed by a test cycle of 1 day. Still, statements of extensive experience always impress me mightily.

Handling holidays or weekends is probably not too difficult since there are no holidays or weekends in historical data. But I do not think that season synchronized WFO cycles can be programmed by script. This had to be implemented in the platform. You may ask Zorro support. They'll implement anything, if not for a good reason, then for good money.

All market parameters like spread etc that change in real time are automatically updated in real time. Any exceptions are broker specific and explicitely mentioned in the manual. Prices in Zorro variables are ask prices. The meaning of a trade ID number depends on the broker. If the broker uses no trade IDs at all, then I guess the number has no deep meaning.

The statistical profit in pips is your wins in pips minus your losses in pips. The profit of a trade is based on the sell price minus the fill price. Whether it's really the fill price depends on the broker API, but as far as I know, all broker APIs report the fill price.

When I have some more time, I will also attempt to answer some of the the rest of your questions.

Re: Trading with Zorro - list of things to clarify [Re: jcl] #467010
07/12/17 09:35
07/12/17 09:35
Joined: Jul 2017
Posts: 783
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 783
Quote:
You can see why adapting WFO cycles to seasons is no good idea when you imagine the consequences of some examples - like a WFO training cycle of 4 calendar days followed by a test cycle of 1 day.

What are the consequences?
"Guns do not kill people. People kill people".

Quote:
Handling holidays or weekends is probably not too difficult since there are no holidays or weekends in historical data

The problem is "Early closes" (related to holidays) and holidays during the week. If not for these, then the 1440(?)/Barperiod solution would be workable.

Quote:
You may ask Zorro support.They'll implement anything, if not for a good reason, then for good money

Great! Does this come with ZorroS?

Is there a "trial" for ZorroS? I am specifically interested to see how Zorro works with IB.

I currently use Multicharts for development, a separate software for WFO and then Sierra for production.
I am excited that with Zorro I can hopefully automate and unify my whole current workflow (besides a host of other great features), but I need clarity on those details before shifting everything from my current set-up.

Re: Trading with Zorro - list of things to clarify [Re: Zheka] #467020
07/12/17 16:34
07/12/17 16:34
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
The consequences of testing only every Friday depend on the strategy, but whatever they are, they are probably no good.

Even normal workdays have often less bars than 1440 in historical data, so that solution would not work.

There is no Zorro S trial, but the free version also supports IB with the restrictions of no volume data and only demo accounts.

Some other answers: For limit orders set the OrderLimit variable, otherwise it's a market order. Entry causes a pending trade, not a limit order. Pending trades are sent to the broker when the entry limit is hit. "Hit" means that the ask price touches the limit. Thaat's for all limits, including stops and TP. If a trade is not filled, it is cancelled. So when you want to still open it, you must enter a new trade. As to my knowledge there is no function that determines the reason of not filling an order.

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1