Trading Hours again using latest add-on...

Posted By: MatPed

Trading Hours again using latest add-on... - 03/10/18 10:52

Hi,
I would like to trade an asset only during the allowed frame. The asset is US-SPX-500 and, accordingly with my broker Oanda can be traded:
Sun-Thu: 23:00 - 21:14; 21:30 - 21:59
Thu-Fri: 23:00 - 21:14; 21:30 - 21:59
GMT Time
Code:
WeekEnd = 4+8;
AssetFrame = UTC;
StartMarket = 23; (or StartMarket = 0; ?)
EndMarket = 2159;


Now if the barperiod is high the gap between 21:14 and 21:30 is not relevant and
Code:
if(!suspended()) enterLong();


should make the trick.

Questions:
- in a multi-asset TS is the approach correct?
- StartMarket 23 o 0?
- to handle the trading gap between the only way is to check the time with lhour() and minute()?

Thank you in advance
Posted By: Zheka

Re: Trading Hours again using latest add-on... - 03/10/18 12:44

It is a US-traded asset, so use AssetMarket=ET - which will take care of DST.
In your example, StartMarket=2300 (why 23??). Since market() does not work correctly when Start>End, you will have to dynamically change StartMarket depending on the hour/minute.
I did not test if suspended() would do the trick in such a case.

Also, be aware that in Zorro EndMarket=2159 excludes 2159 (despite the whole world around works otherwise). You will have to set it to +1min to make it work as expected.
This will be important to handle bar construction around weekend.

If you use the same BarPeriod across assets, then working with AssetMarket/AssetFrame will be ok.
However, since your data contains gaps, standard frame construction(which just counts bars) will produce incorrect frames (unless you use full-hour frames and framesync() them to start from the same hour every 24-hrs).

If different StartMarket/EndMarket per asset in the same zone will work correctly - I am not sure; probably not.

If end of your Bar/Frame falls onto the gap - you will then have to use lhour() and minute(). What's wrong with it?
Posted By: MatPed

Re: Trading Hours again using latest add-on... - 03/10/18 15:45

Zheka, thank you for your reply, but I do not understand.
The US SPX 500 can be traded.

Sun-Thu: 23:00 - 21:14; 21:30 - 21:59
Thu-Fri: 23:00 - 21:14; 21:30 - 21:59
GMT Time

or (is equivalent)

Sun-Thu: 17:00 - 15:14; 15:30 - 15:59
Thu-Fri: 17:00 - 15:14; 15:30 - 15:59
Chicago Time not ET

can you suggest me how to properly set:
- Weekend
- AssetMarket
- StartMarket
- EndMarket

Thank You




Posted By: Zheka

Re: Trading Hours again using latest add-on... - 03/10/18 17:02

It will be 18:00 - 17:00 ET, isnt' it?

StartWeek=72100;
EndWeek=52200;
Weekend=1+8;

If you only plan to trade US assets/FX and trade during all of the open hours, then there is no need for setting AssetMarket/StartMarket.

If you want to restrict your trading to stock exchange trading hours (while there are bars available for 23 hours), then you would use:

AssetMarket=ET;
StartMarket=900;
EndMarket=1500;
Posted By: MatPed

Re: Trading Hours again using latest add-on... - 03/10/18 17:21

I don't think it will work.
I am trading several assets with different market time. The VPS and the broker's server is UTC time. Oanda stops the server during weekend. For stability purposes is better to use Weekend = 4 I guess that start week will mess up everything. I do not want to restrict trading to stock Exchange Trading Hours.

Zheka, have you experienced with this setting in a TS Live? I want to fine tune a 23 assets TS already live. Zorro syncronize all the orders placed outside market hours, but the broker server send me a lot of error messages. On top of that the broker is aware, in advance, what I am willing to do. Oanda is a MM...

Posted By: Zheka

Re: Trading Hours again using latest add-on... - 03/10/18 17:42

What I wrote is "conceptual" and should work in Test mode.
VPS/broker's server actual time zone has no bearing on your system.
Since you trade different time zones, just use ltod,etc with the zone of the respective asset.
I do not have experience trading through Oanda live and tuning systems for that.
Posted By: MatPed

Re: Trading Hours again using latest add-on... - 03/10/18 17:55

Thank you for your help and honesty.

From the manual:
Make sure that the time and the time zone of the VPS is set up correctly. It does not matter which time zone - you can either use your PC's time zone, or the VPS time zone, or any other time zone - but the VPS time must be correct and match the zone. If it is wrong, Zorro will display a wrong UTC time in the server window, and strategies based on market open and close times - such as gap trading - won't work anymore. If in doubt, set the VPS to the time and time zone of your PC at home.
Posted By: Zheka

Re: Trading Hours again using latest add-on... - 03/10/18 19:50

The manual means that if you specify your VPS time zone as UTC (in Windows), then make sure that the date,hour and the minute actually reflect UTC time.

In live trading Zorro timestamps incoming ticks (and ends bars) as per local computer time (+/- time zone difference vs. UTC).
So, it is quite important to regularly sync your computer clock to the atomic reference.
There are several utilities for that and a number of different servers to sync to. Google is your friend.
Posted By: MatPed

Re: Trading Hours again using latest add-on... - 03/10/18 20:07

Yes, you said that "VPS/broker's server actual time zone has no bearing on your system", but it is not fully correct.
In order to avoid issue I have aligned, VPS, Zorro and Broker Server Time. On top of this there is the weekend downtime of the server to take in consideration.

I can setup a demo account and test the different settings, but it is time consuming. I was looking for somebody with "live" experience in order to reduce the effort.
Posted By: Zheka

Re: Trading Hours again using latest add-on... - 03/10/18 20:38

Quote:
VPS/broker's server actual time zone has no bearing on your system.
is in line with
Quote:
It does not matter which time zone - you can either use your PC's time zone, or the VPS time zone, or any other time zone - but the VPS time must be correct and match the zone
Anyway, wishing you a good deal of luck.
Posted By: MatPed

Re: Trading Hours again using latest add-on... - 03/10/18 21:52

Thank you, I wish greater luck to you.
© 2024 lite-C Forums