Gamestudio Links
Zorro Links
Newest Posts
What are you working on?
by rayp. 01/22/22 00:55
Lapsa's very own thread
by Lapsa. 01/21/22 08:23
Generic, dynamically growing array
by 3run. 01/18/22 15:37
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 01/18/22 15:00
Bug in NumUp/Dn
by jcl. 01/17/22 12:23
Help with plotting Lookback in Trade Mode
by degenerate_762. 01/15/22 23:43
AUM Magazine
Latest Screens
Tactics of World War I
Hecknex World
Scheherazade's Journey
Paradox Vector
Who's Online Now
5 registered members (Zheka, ozgur, AndrewAMD, gamers, NorbertSz), 168 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
kawjansen, Alex2052, AndreasTrader, spacenomad, coinpump
18731 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Basic Time Windowed profit taking #484666
11/27/21 03:19
11/27/21 03:19
Joined: Sep 2021
Posts: 9
Waikato
T
TimExcellent Offline OP
Newbie
TimExcellent  Offline OP
Newbie
T

Joined: Sep 2021
Posts: 9
Waikato
Hi I'm not a coder at all, but have learnt/hacked some basics and bodged something together myself today, I'm working with a developer on this for a complete trading strategy and trying to adapt a script I found that I got running (all by myself!) for a basic backtest to figure out some thresholds for myself - trying to be more useful! (currently it trades far too much - which was the purpose of the script from Robot Wealth course I'm doing, but it has the bare bones of what I'm trying to at least just test and then export different thresholds to an excel sheet where I'll do the rest of my data work)

So I downloaded raw SPX Tick and 1 minute data (the strategy is intraday) which I have successfully saved as .t6 format from my broker, so initial parameters look like this:

// Simulation parameters
setf(PlotMode, PL_FINE);
set(PLOTNOW);
BarPeriod = 15;
StartDate = 20210105;
EndDate = 20210130;
History = "*.t6";
LookBack = 20/BarPeriod*6.5;
assetList("AssetsTS");
asset("SPX");
MaxLong = MaxShort = 1;
//

I then parse the .t6 data through a static var function to build up bars to calculate volatility vars vol = series(sqrt(Moment(returns, 20/BarPeriod*6.5, 2))), then I have a stdev threshold for entry. But I then want to take the derived data from my stored parameters and then enter into an option contract which is a .t8 format - how do I do that, do I need to define another function that addresses the Options data I have?

So I'm calculating from the Underlying Price data and then wanting to trade the derivative contract/options.

I then need to add a second piece of trade logic snippet to take the entry signal (eg. 2.0 stdevs) and then tell Zorro to look for .t8 files in History folder:

1. Will Zorro know to also check the same Start and End Date as the Simulation parameters above, or do I need to define a Start End Date function that both the Price series and Options series would look at seperately?
2. Does anyone have a basic Long Straddle code snippet they could share? I'm having trouble unpicking other examples I've found of options strategies, it is just for an ATM Straddle when the threshold Stdev's are met.
3. Any tips on how to create and store "At The Money" price series to enter the straddle? I dont think I even have to really, as I just want to enter a Long Put and a Long Call at the exact stdev condition being met at this point, so really its just trade the closest strike
4. Is there an export data to excel/csv function?

Thanks

Re: Basic Time Windowed profit taking [Re: TimExcellent] #484667
11/27/21 11:18
11/27/21 11:18
Joined: Apr 2008
Posts: 434
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 434
Austria
Call contractUpdate at any bar in the backtest, then the contract function to find the at the money contracts.

There are some script examples for options trading.

For exporting data to csv you can use print(TO_CSV,...) or dataSaveCSV.

Re: Basic Time Windowed profit taking [Re: TimExcellent] #484674
11/28/21 00:16
11/28/21 00:16
Joined: Sep 2021
Posts: 9
Waikato
T
TimExcellent Offline OP
Newbie
TimExcellent  Offline OP
Newbie
T

Joined: Sep 2021
Posts: 9
Waikato
Thanks Petra, is defining DTE 0 or the contract look up being days to expiry 0 enough for zorro to know to look for contracts expiring that day, or would I need to specifically give it a fractional time based expiry window?

Also I noticed in the contract.c file that the calculations use 365.25 days, usually I think traders in pricing models use 252 days which is the number of trading days roughly in a year - is there a good reason to stick with 365 days in the calculations there that you have found or just havent been asked?

Last edited by TimExcellent; 11/28/21 03:44.
Re: Basic Time Windowed profit taking [Re: TimExcellent] #484675
11/28/21 07:38
11/28/21 07:38
Joined: Apr 2008
Posts: 434
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 434
Austria
DTE is always in calendar days. For expiring same day, use DTE 0 or the current date in yyyymmdd format.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1