Systems Workshop: "Buttonwood" E-mini daytrading system

Post anything related to mechanical systems and automated trading here.
shwh
Posts: 15
Joined: Fri Jul 24, 2015 8:54 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by shwh » Thu Oct 15, 2015 2:00 am

Just a thought but if the 'system' is going to be using astro info, why not use a 4m chart so that each bar equals a 1* rotation of the Earth?

User avatar
earik
Site Admin
Posts: 474
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by earik » Thu Oct 15, 2015 4:46 pm

The part of this that is based on astro isn't sensitive enough to 1min changes in calculation granularity (like from 5min bars to 4min bars), so I just started off with a 5min chart by default. I haven't tried this on any other time frames, so this is actually a very good suggestion. Working forward, whenever we come across something like this that could have a big impact on system performance, I'm going to bold it in red font, like this:

Possible Improvement:
What time frame does this system work best on?


That way if someone is cruising through the thread and has some time to burn, they can stop at one of the red items and dig a little deeper. It might turn out that this approach works way better on a 4min chart, or 15min chart, than it does on a 5min chart, and that would definitely be a good thing to chase down once we've got something more complete in place. Now that you mentioned it, I'm pretty curious what would happen on longer time frames, like 60min charts, since there's a lot of noise on the faster ones that wouldn't be present there...

Thanks!

Earik

User avatar
earik
Site Admin
Posts: 474
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by earik » Thu Oct 15, 2015 11:38 pm

Introducing our Weather Forecasting function and building Buttonwood_v1

We now have everything we need in order to build a working system except for our market weather forecasting function, which I'll talk about now. If you've read any astrotrading books (mine included) you'll find that the emphasis is almost overwhelmingly on trying to use astro to locate turning points. That works, and is definitely one way to approach the subject, but there are other ways to use this information, and I think the desire for being able to call tops and bottoms really blinds astro researchers at times. I know that definitely happened to me in my early years working with this stuff.

The other way to approach this field is to think in terms of volatility. In other words, when lots of planets line up in particular configurations, rather than look for a turning point in the market, what about looking for an increase in volatility? Going back to traditional astrology, the birth chart, or natal chart, is like the "antenna" of the individual. When various things happen in the sky to trigger that antenna, then events occur to that person. That's why one person can be having a crappy day, while another one is just going about their business without any issues - that first person is having a bad aspect, while the second person has a different natal chart, and isn't absorbing any of that energy.

Anyway, back at the beginning of this thread, we looked at three different planetary wheels from the ephemeris: 1) the natal chart, 2) the progressed chart, and 3) the current (or "transiting") planets. The first one is fixed, and is there from birth, the second is the birth chart spun around at a given rate, like a bezel on a watch, and the third is the position of the planets as they appear in the current moment. What we want to do is use this information to tell us when the market will have a big day, and when the market won't. In other words, we're going to build an algorithm that tells us how hard the market's antenna is getting hit.

So first off, let's figure out what the market's birthday is. This is actually kind of a can of worms, since there are multiple answers to this problem. For the S&P, there are four common answers:

1) The first trade date of the big S&P 500: 4/21/1982
2) The first trade date of the actual EMini futures: 9/9/1997
3) The birth of the NYSE itself: 5/17/1792
4) The corporate reorganization of the NYSE: 2/18/1971

Those of you who have used some of the astro tools in W59 might recognize some of these dates, especially the first one. I haven't gone through the entire list of possibilities, but just jumped right to the third one with this system. Back in 1792, a number or stock brokers got together and agreed upon how the NYSE would function. This was considered the first meeting of the organization, and is known as the Buttonwood agreement, singed by 24 brokers under a buttonwood tree, on Wall St. There are different times that this is thought to have happened, and a quick Google search should give you a few. Jack Gillen says 8:52 AM, Eastern Time, which is the one I chose in the functions. I'm not sure who's right, but we have an optimizer, so we can actually do some solving ourselves for this later.

Now that we've got the date, we can look at our three wheels, which give us three possible solutions:

1) Current Planets vs Natal Planets
2) Progressed Planets vs Natal Planets
3) Current Planets vs Progressed Planets

We can measure "energy" in those three ways, and we do so simply by counting up hits from one wheel to the other. So, for the first option, we start with an index value of 0, and then we look at each planet in turn. If it is within 1 degree of a natal planet, add 1 to our index. Compare all the combinations, and you get an indicator that will give you a higher value when there is more interaction between those two wheels, and a lower value when there is less interaction. I've build functions for all three, which I've included in the attachment to this post.

So that's how we'll measure market weather, which is the last piece of the puzzle. Here's our first script:

Code: Select all

#Trades simple moving average crosses, but only on days with hits
#on Buttonwood chart
#thresh = we have to have this many hits on our chart to get permission to trade
#orb = how many degrees to allow in order to count a hit
#correction = how many days to add or subtract from Jack Gillens 1792 date

input:thresh(3),orb(1),correction(0.25);

#init variables - this block only happens once at the beginning
if (barnum==barsback)
{

    signal = 0;
    bs = 0;
    ok_to_trade=false;
}

#market weather computation ----------------------------------

#index=Buttonwood_Index_CurrentToNatal(orb,correction);
#index=Buttonwood_Index_CurrentToProgressed(orb,correction);
index=Buttonwood_Index_ProgressedToNatal(orb,correction);

ok=false;
if (index>=thresh) ok=true;


#compute trading signal --------------------------------------

signal = Buttonwood_Signal(8,34);

#actually place trades ---------------------------------------
if (ok==true) {
    if ((signal>0) and (bs<=0)) {
        buy(1,close,"market","onebar");
        bs=1;
    }
    if ((signal<0) and (bs>=0)) {
        sell(1,close,"market","onebar");
        bs=-1;
    }
}
else {
    if (bs!=0) {
        exitlong(0,close,"market","onebar");
        exitshort(0,close,"market","onebar");
        bs=0;
    }
}

#end of day exit
if (time==endtime) {
    exitlong(0,close,"market","onebar");
    exitshort(0,close,"market","onebar");
    bs=0;
}  
I've tried to keep this code as clean as possible, knowing that some of you will want to get in there and poke around. If you ever get confused about what I was doing in a particular section, please ask! Note that I've got three different functions for market weather, since I wanted to provide everything, but we are only using the last one. That's because I ran a test on each, and got the following results, from 1/1/2009 through 10/15/2015:

Raw (no filters): $11.69 average trade
Current To Natal: $19.65 average trade
Current to Progressed: $8.65 average trade
Progressed to Natal: $28.19 average trade

Only Progressed-to-Natal gets us close to our breakeven point, although Current-to-Natal makes an argument for more investigation. Current-to-Progressed was horrible, even worse then no filter at all. That might mean we need to trade when Current-to-Progressed is low, rather than high. I'm putting that in red! Someone check it out!

When you go through the index functions, also note that I've only considered "hits" when one planet is either conjunct (same degree), or opposed (180 degrees) away. That might not be the only appropriate configuration, and most astro finance types would argue for more aspects to be added. That's another one to take a look at as we build this out.

Let me take a minute and talk about the "correction" input. Since we don't know whether Jack Gillen's time was correct, that input lets us move our natal date forward and backward by a fraction of a day. So an input of "1" would push the entire natal date forward to the exact same time on the very next day. I ran a quick optimization report, and found the following results:
optimizing_buttonwood_filter.png
Rectifying the Buttonwood Natal
optimizing_buttonwood_filter.png (62.96 KiB) Viewed 27057 times
Note that a much better natal than Jack's is actually a quarter of a day later, using the value of 0.25. This needs to be fine tuned more than I've done, but I think I'm pretty close.

Anyway, here's the full system report right now:
system_report_v1.png
System Report for Buttonwood_v1
system_report_v1.png (31.89 KiB) Viewed 27057 times
Not quite awesome just yet, but it's at least to break even, and is a huge improvement over the original in that regard. Keep in mind that the system we are using here is just 8/34 moving average crossovers, which is not exactly the pinnacle of technical analysis. ;) We are just trying to find those days when the market likes to trend, and we are definitely making some strides in that direction if we are able to eke out even small profits using a simple moving average crossover system.

Here's the equity curve:
equity_v1.png
Equity Curve for Buttonwood_v1
equity_v1.png (33.17 KiB) Viewed 27057 times
I actually look at the equity curve plot first, before anything else, and think it is the most important piece of a system report. This one is looking very promising.

So, there you have it. Our first version. Lots of work to do still. To be thorough, I'm going to add some red items, which hopefully some of you will be willing to follow up on as part of this project:

Possible Improvements:
1) What is the best "correction" setting? Optimizing between -1 and 1 in small steps is the way to find that.
2) Is there a better natal date than the Buttonwood agreement that we should be using instead? How do the other 3 look?
3) We only consider conjunctions and oppositions. What about other aspects, like squares (90 and 270) or trines (120 or 240). Do they have a polarity? In other words, do all aspects add volatility, or do some reduce it? If we have reducers, we need to subtract them from the index rather than add.
4) What's up with current-to-progressed giving us worse results than the raw system? Sounds like a volatility-reducer to me! Significant enough to work in?
5) After all of that is figured out, we need to find the correct "thresh" value, which tells us what the index needs to be in order to allow us to trade.


All for now. One last point, I'm using IQFeed's @ES#C symbol, which they'll give you going back pretty far. I started in 1/1/2009, which gives us almost 8 years to test on. 2008 also works, but it tends to skew results a little, since there was too much money to be made that year. You can use it or not, but I think 8 years is plenty for an intraday system like this. 1226 trades is putting us in the "statistically significant" arena, at least in my experience. To download the scripts, just get the zip file (attached), unzip, then double-click and W59 will handle the rest.

All for now!

Earik
Attachments
buttonwood_v1.zip
(4.68 KiB) Downloaded 490 times

alexashka
Posts: 9
Joined: Tue Jul 21, 2015 8:51 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by alexashka » Fri Oct 16, 2015 1:06 am

Hi Earik & W59,

I safely suspect you tested it on classical astrology, what about etheric? (correction for ether) May be etheric astro would give better results in comparison to raw?

Thank you. Alex.

User avatar
Feinberg
Posts: 54
Joined: Wed Jul 22, 2015 10:18 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by Feinberg » Fri Oct 16, 2015 10:16 am

As long as we are trying to build a trading system on the ES, shall we include the Vortex?
Last edited by Feinberg on Sat Jan 02, 2016 8:11 pm, edited 2 times in total.

User avatar
Feinberg
Posts: 54
Joined: Wed Jul 22, 2015 10:18 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by Feinberg » Fri Oct 16, 2015 10:20 am

Here is the actual chart file.

[zipped file deleted. only downloaded six times]
Last edited by Feinberg on Sat Jan 02, 2016 8:13 pm, edited 3 times in total.

User avatar
Feinberg
Posts: 54
Joined: Wed Jul 22, 2015 10:18 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by Feinberg » Fri Oct 16, 2015 10:24 am

And here is an example on how you can started for today............
Last edited by Feinberg on Sat Jan 02, 2016 8:14 pm, edited 1 time in total.

User avatar
earik
Site Admin
Posts: 474
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by earik » Fri Oct 16, 2015 6:03 pm

Hi Guys,

Thanks for the suggestions. I haven't tried etheric (or spherical), and those would definitely be good ones to investigate. You can see how many paths start opening up once you stumble onto something that works!

With an approach like this, it has to be 100% automatic, where W59 does all the calculations and places the trades itself, in a hands-free way. The Vortex, as great as it is, is probably the most challenging tool to automate in that way, and is not something I've got code for. So unless you can figure out how to get automatic targets out of it via some fancy algorithm, it's not really on the table as far as a technique that we can throw into the mix for this system. The downside to automated systems is that you lose a lot of the really cool discretionary tools that you have access to otherwise, but the upside is that you are able to figure out exactly what your edge is via the system reports, and are able to backtest that edge quickly and reliably (and repeatably!), which in my opinion more than makes up for the limitations as far as what you can throw in there.

Regards,

Earik

User avatar
earik
Site Admin
Posts: 474
Joined: Mon Dec 01, 2014 12:41 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by earik » Fri Oct 16, 2015 9:30 pm

Buttonwood_v2: adding a spherical filter and fixing a couple bugs

I had some time this afternoon, and built a filter based on spherical astrology, which I've had very good results with when building mechanical systems. I've also fixed a couple bugs, both in the loop counters for the CurrentToNatal and CurrentToProgressed filter, which slightly changes their results. I'll post the updated results a few paragraphs down. First let's talk about Spherical Astro. I discussed this in a lot of detail in the 2011 PUC, so that's the place for theory, and there's also some in the MTS book. Basically, what we're doing here is looking at the solar system in 3D, rather than in 2D like most astrologers. When we do that, the timing of our aspects changes, oftentimes quite dramatically, with the results that triggers which used to not work all of a sudden get "fixed". It's a huge step forward in being able to use astro in mechanical systems, where we really need a hard edge to work with.

Anyway, what I did was build a function that computes our market weather index based on Spherical calculations. It's harder to get conjunctions and oppositions when using spherical astro, so I did a quick run to test various different aspects in steps of 15 degree increments to see if any of them were "hot" or not. Here are the results:
buttonwood_spherical_aspects.png
Spherical Aspect test
buttonwood_spherical_aspects.png (55.95 KiB) Viewed 27030 times
If you look at the average trade column, you'll see hits at 15, and at 90. There's also a hit at 0, but there was only one trade there. That tells us that conjunctions are important (towards aspect value of 0), as well as squares (90). That's *exactly* what I was expecting to see, and fits in very well with the known theory behind this approach. So this is more than just cranking through and looking for silver bullet number combinations that work - it actually confirms what we already know about spherical astro.

As I mentioned, conjunctions are hard to get with spherical, because rather than two planets being at the same degree value, they have to be at the same degree and declination. In other words, conjunctions are now eclipses, and those are rare. That's why there weren't very many trades when our aspect value was 0, compared to the others. But we can see that it's an important configuration, so what I did was go back and run the test with aspects closer to zero, in steps of one degree:
buttonwood_spherical_aspects_conjunctions.png
Conjunction exploration
buttonwood_spherical_aspects_conjunctions.png (61.26 KiB) Viewed 27030 times
Again, looking at the average trade column, it looks like things get hot when we get within 8 degrees of an exact conjunction, which gives us something to work with. So our index value is now computed when a current planet is within 8 degrees of a conjunction, or at a 90 degree aspect (1 degree orb) of a natal planet, as measured using spherical astro. I didn't know what to do with the 15 degree aspect, since it's a minor aspect in the whole scheme of things that I don't usually work with. So I just ignored it. That's completely a judgement call, but I like it better when the theory and the numbers work together. Anyway, we've got lots of trades now, which is going to change our thresholds a bit, so I went back to the optimizer to see what they looked like. Note how useful an optimizer is, and how we're not using it to solve for values as much as we are to look around the search space to see where the gold lies.
spherical_thresholds.png
Thresholds
spherical_thresholds.png (17.61 KiB) Viewed 27030 times
The main thing to notice here is that our average trade increases alongside our threshold value. So we start out at $15.63, and run up to $44.19 (nice!) at a value of 6. Then the number of trades gets too small, and the numbers fall off (which is ok). This is exactly what we want to see - higher index values mean a higher average trade, which means that the moving averages are getting better traction. That was our theory when we began building these weather functions in the first place, so the idea is getting proven out by the numbers.

Here's what the equity curve looks like, at a threshold value of 4:
spherical_threshold_of_4.png
Equity Curve for spherical, using threshold = 4
spherical_threshold_of_4.png (32.14 KiB) Viewed 27030 times
That's a different kind of equity curve than before. The flat lines are when the spherical filter goes quiet, telling us there's not enough volatility to trade a trend-following approach. Then the index comes back up, and we trade again. So you get a sort of stair-step pattern. In the end, we might need to merge a couple of these together to get a more even trading distribution during a year, but we need to know all the profiles first.

I mentioned that I fixed a couple bugs in the other filters. (Welcome to programming! :? ) After fixing them, and adding spherical, we have the following new average trade list:

1) Raw = $11.69 (as before)
2) Current To Natal = $15.86 (reduced from previous test)
3) Current to Progressed = $13.81 (improved from previous test)
4) Progressed to Natal = $28.19 (same as before)
5) Spherical Current to Natal = $25.76 at threshold 4 (new)

So the second and third filters slightly improve results, but only slightly. Probably should still look at aspects there, but I'm not sure if CurrentToProgressed is going to be an anti-volatility indicator as I had hoped last time. Spherical is looking VERY promising though, and i can see how we might consider combining it with progressed to natal. We also should check out Spherical Progressions.

Anyway, I've attached Buttonwood_v2, which contains the new scripts. I'll just keep adding new versions to the end of it, so we've got a way to go back and forth with what we are doing here.

All for now. Have a good weekend!

Earik
Attachments
buttonwood_v2.zip
(5.8 KiB) Downloaded 481 times

zenbl421
Posts: 3
Joined: Mon Aug 24, 2015 5:17 pm
Contact:

Re: Systems Workshop: "Buttonwood" E-mini daytrading system

Post by zenbl421 » Sat Oct 17, 2015 12:54 am

Thank you Earik,
This is very educational, to see the thought process and the choices.
Scott

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests