Price action works. But why?

jcl
Trader
Posts: 82
Joined: Wed Oct 31, 2012 8:04 am
Location: Frankfurt / Germany

Re: Price action works. But why?

Post by jcl »

Over-fitting is generally a problem of all machine learning algos, so out of sample is mandatory. The pattern algo that I uploaded was the last algo file of a WFO series. So when you test it with recent price data you'll probably get a too optimistic result. For a realistic result you'd need a WFO able platform for testing the whole series. The C script that generates and trades the patterns is this:

Code: Select all

function run()
{
	StartDate = 2002;
	BarPeriod = 24*60; // 1 day
	NumWFOCycles = 5;

	set(RULES|TESTNOW|LOGFILE);
	if(Train) {
		set(HEDGING);     // allow long & short
		TimeExit = 5;     // 5 bars price movement
	} else {
		Stop = 500*PIP;   // large stop distance
		TimeExit = 10;    // twice the prediction horizon
	}
	
	if(adviseLong(PATTERN+2,0,
		priceHigh(2),priceLow(2),priceClose(2),
		priceHigh(1),priceLow(1),priceClose(1),
		priceHigh(1),priceLow(1),priceClose(1),
		priceHigh(0),priceLow(0),priceClose(0)) > 30 and dow() != FRIDAY)
		enterLong();
	
	if(adviseShort() > 30 and dow() != FRIDAY)
		enterShort();
}
The adviseLong / adviseShort functions in the script are explained here: http://manual.zorro-trader.com/advisor.htm. A trade is entered when the pattern score is > 30 and when it's not Friday. The Friday condition is in-sample. I also do not have a real explanation why Friday trades are not good for pattern trading. But it happens also with other currencies. I've written some explanation in the manual, but I'm not sure about it. Anyway when I omit the dubious Friday condition, the out of sample profit is still in the 100% range. I get even better profit when I use a fuzzy pattern match instead of the strict pattern match in the example.

The trades just exit by reversal, and also after 2 weeks, which is twice the prediction horizon. I believe after 2 weeks any correlation between the price and the pattern is gone. The strategy can certainly be improved by a better exit algorithm.

The signals within a function are certainly mutually exclusive. I haven't tested if Long and Short signals are mutally exclusive, but I think they are - it's highly unlikely that the same pattern gets a positive score both for long and for short trades.
garyfritz

Re: Price action works. But why?

Post by garyfritz »

I don't see any cases (going back to 2003) with Long & Short signals > 0.

Ah, so the pattern algo you posted includes recent history, so it's only good for realtime trading? How often did you re-train, and on how long a training period, for the WFO results you showed in the first post? In other words, how long are your IS and OOS periods?

OK, enter long/short when score > 30 and not Friday. Hold for two weeks with a 500 pip stop. If you get another signal in the same direction, do you reset the two-week counter? If you get a reversing signal while a signal is open, I assume you immediately reverse and hold that one for two weeks?
jcl
Trader
Posts: 82
Joined: Wed Oct 31, 2012 8:04 am
Location: Frankfurt / Germany

Re: Price action works. But why?

Post by jcl »

Yes, the algo file is only good for real trading, but here are the other 4 files from the WFO series:
Workshop7_EURUSD_4.zip
The simulation period is 4.4.2002 - 23.4.2012. I trained 5 times with 417 weeks each, the last cycle is for real trading. The 4 test cycles are 73 weeks each.

When another signal gets in the same direction, another trade is just opened. Reversal closes all open trades in the opposite direction and opens a new 2-week trade.
You do not have the required permissions to view the files attached to this post.
jcl
Trader
Posts: 82
Joined: Wed Oct 31, 2012 8:04 am
Location: Frankfurt / Germany

Re: Price action works. But why?

Post by jcl »

Ah, and before I forget - for testing the algos you need daily candles that start at 00:00 UTC. Candles with some local time offset would require different patterns.
garyfritz

Re: Price action works. But why?

Post by garyfritz »

Ah. So if I get long signals on days 2, 4, and 6, and then short signals on days 8 and 10, I'll build up to 3 long positions on day 6, then reverse to no long and 1 short on day 8, 2 short on day 10?

5.7:1 is a good IS:OOS ratio. I've generally used 4:1 but 5.7:1 should be good. 73*5 = 365 candles OOS is probably OK, but I wonder if a shorter OOS would work better.

My daily candles start at 5pm NY time = GMT+2 or GMT+3, depending on summer time. I wonder how sensitive it is to those differences? If necessary I could run on intraday data with whatever day-start time I want, but that's messier.

I'll go play with this in my copious free time :roll: and see if I can get any insights into the "WHY" of it... Thanks jcl!
giailang
Trader
Posts: 18
Joined: Wed Oct 24, 2012 10:57 am

Re: Price action works. But why?

Post by giailang »

IMO, the nature of this is momentum counting, in same vein as VM's I Ching. Technically, VM counts the momentum in both ways: up and down with up as addition and down as substraction to the total value. The number 30 can be seen as threshold to switch from unidentified market state, to trending market.

As you found that Friday is filtered out of the trade. This day of week shows the widest volatility at both sides of the meridian line of the prices which the momentum counting models of WFO and VM do not fit for trading this day.

The reason for this is that both models shared momentum counting sum, of which the fluctuation is linearised, real noise/entropy has been compensated by the summation. In signal processing, this thing has been called as noise cancellation or "dampen", of which, the filter process rips off not only noise, but also parts of the signal. You have momentum sum equals 0 for many cases, i.e. -64+64 and -50+50. This is bias that the said models should avoid.

On Friday, it seems that mechanic trading systems are more active to get profit from order flows instead of price offset; many systems are failed on this day, include momentum counting scheme.

All aforementioned things of market structure on Friday are my guesses/ suppositions without any facts to supports. Hence, readers should take it into account.
Post Reply

Return to “Automated trading systems”