A programmable trading plan using only price bars

Rather shamelessly, I am quite tempted to look at Dunnigan's definition of trend again.

The trend is currently up if the below are true:
- If we start from the current bar and go back bar by bar, we should find a swing low the range of which is entirely above the preceding swing low, or we shoud find an an up bar in an upswing that has closed above the preceding two swing highs. Once such a point (call it bar A) has been identified, two things must happen:
a. No bar in the downswing immediately following bar A should be completely below the range of bar A.
b. The first up bar that follows the downswing following the the point A should close above the close of the previous bar (i.e. the swing low bar).
- Between point A and the current bar no signal for downtrend must have appeared.

Once bar A is identified, we can go back further to find where the uptrend started. It will be the bar that satisfied all the condition of uptrend since a signal of downtrend appeared.

Once an uptrend is established, it remains in effect until a signal for downtrend has appeared.

Complicated? That's why I had decided not to use it when I looked at it before. I will now take some time to digest it and look at some charts to see how it fits with my temperament.

your above post reminded me, dont know why, of Marc Rivalands "Swing Trading", and his use of Swing highs and lows, and defined change of trend when an existing swing high or low was broken.

Its one of the first trading books I ever bought, and has one of the few, (to me), rules for defining trend and reversals using only the behaviour of price bars and no indicators whatsoever, although he later desrcibes using RSI as a filter.

its pretty oldish, but your project has just reminded me of Rivallands definitions.
I mention this only becuase his definitions were simpler!!

(Marc Rivalland on Swing Trading. my copy www.harriman-house.com)
 
I remember the other reason why I didn't like it the first time. I have rephrased Dunnigan's definition slightly here. Actually, in his definition of uptrend, he starts counting not from the current bar and backwards, but from what he calls 'maintrend low' and forward. Except to define 'maintrend low', you need to go back to the prior 'maintrend high' and to define that you need to go back to the 'maintrend low' before that and so on and so forth. So it's not really as well-defined as I want.

Or may be I am obsessed with definition and should see a doctor...

If you want a "mechanical" trend, how about using the Parabolic SAR ..you can change the standard settings to suit.
 
With the definition of the trend out of the way (using Dunnigan's definition for the time being), I need to again concentrate on when to scratch and how to take only trades that are good value.

I have a few ideas on both. Will write down when I have some time next.
 
Changed my mind. Instead of glossing over trend, I will for the next few days look at the chart of ES and understand how the definition of trend pans out. Is our definition of a reversal more or less catching the turning points? Is it too late? Too early? What does it look like in a choppy market? Are we better off trading just the reversals or the swings? Or both?
 
One idea on scratching that has been forming in my mind for some time:
Immediately after a long entry, if the next bar closes in the bottom half, we scratch the trade. Similarly for shorts. The rationale is that we are trading swings, we have taken an entry just after what we believe an end to a pullback. We don't expect to see selling coming into the market so soon.
 
Last edited:
The other type of early exit could be when we see serious hammering against our direction, an example of which is what people call upthrusts, wide range bars pushing up but closing near the lows. I have not done enough work on that yet, Defining them should not be difficult, but I have not decided if we should exit immediately or simply tighten the stop.

PS. Boy this is gonna be a long haul this trading plan business.
 
One idea on scratching that has been forming in my mind for some time:
Immediately after a long entry, if the next bar closes in the bottom half, we scratch the trade. Similarly for shorts. The rationale is that we are trading swings, we have taken an entry just after what we believe an end to a pullback. We don't expect to see selling coming into the market so soon.

if your definition of trend encompasses several dozen bars, bailing out after one down bar after entry seems like reacting to noise. it could be a spurious, narrow, sideways breather before the move proper gets underway.

its really tough this!

EDIT: some simple ideas on trend ans Sup/Res trading, using just price-based rules. hope it helps. (I dont use any of them, but am a big fan of Seykota. There are many articles on risk/reward, etc )

New Page 1
 
The reason for the journey ?

mmm, I think it might help if you(anybody) can see it first. Totally.(they are satisfied with the knowing) Then I think for some the next challenge might well be can I automate this.

Why automate ? how would you spend your hours working otherwise? whats the reason?

just checked first post, emotion, subjectivity etc.... is it not just a responsibility issue ? I can see the challenge about attempting to program but not on the basis of my own emotion /subjective ownership of fluid trading decisions. I think to program a person would need to go through all that first to be happy enough to conceptualise what it is needs to be done via machine, to, now can it be done? :) sort of thing.

Interesting why people may want to hand the job over to a machine if they enjoy doing the job in the first place...... ?

Im just flashing around thinking, maybe someone else more qualified can see what route you are trying to walk and chuck something in..

but yeah tough ,especially if the gameplay needs to be ingrained in the human before that human attempts to install that into a box. big challenge. (y)

All the best with it..
 
Trend signals from the first half of today's ES.
 

Attachments

  • Untitled.PNG
    Untitled.PNG
    36.3 KB · Views: 287
Looking at the chart, this definition of trend was quite late in picking the reversal points. I haven't posted the chart but the performance for the rest of the day wasn't that great either.

I must admit I am less inclined on this definition once again. If something is a fairly complicated beast to compute and internalise, then it'd better be special.
 
The hell with it. I want a simple life and a simple trading plan (after all that's why I am looking at just price bars and nothing else). A moving average as a trend indicator is not perfect but it will have to do. Nothing is perfect.

Updated trading plan (changed bits in bold):

Trade only the ES with a 1min bar chart and a 15-period triangular moving average.

(Strategy for longs, reverse for shorts)

If the 15-period triangular moving average is non-declining then the trend is up and vice versa.

Set-up 1: A swing low should form, and the up bar following the swing low bar should close on the top half. Buy when the high of the up bar is broken.

Set-up 2: A closing price reversal has occurred. Buy when the high of the CPR bar is broken.

A long set-up is cancelled if either of the following happens:
- The moving average turns down.
- A down bar appears before the signal bar is breached.

Management (for longs, reverse for shorts):
The initial stop and also the normal place for the trailing stop is below the swing low. However, on entry, as soon as we have 3 up bars in a row, three different management schemes will be employed.
First, One unit will be closed.
Second, the stop for the second unit will be trailed below the 3-bar lows.
Third, the stop for the last unit will be trailed below the swing lows.

If the bar immediately following entry (i.e. the bar that breaks the high of the swing low bar and get us into the trade) closes in the bottom half, the stop for the entire position will be tightened to below that bar.

Note: 'Below' with reference to stop placement means one tick below the bar in question. One tick for ES is quarter of a full point.

There are still two areas on which I need to work on:
1. Other price patterns which would trigger the closure of a trade or tightening of stops (e.g. upthrusts).
2. Taking only 'value' trades.

PS. Dbphoenix would be no doubt be disappointed with me succumbing to the lure of the moving average again. Sorry. I had to take a decision now.
 
Last edited:
Note to myself: outside bars and long range bars are different things... to be elaborated and dealt with later...
 
PS. Dbphoenix would be no doubt be disappointed with me succumbing to the lure of the moving average again. Sorry. I had to take a decision now.

Not disappointed. I've seen this movie many times before. Everybody has to go through the process.
 
Thoughts so far on 'value' trades:

The most basic way of ensuring that we do not take undue risk is to have a hard limit, e.g. 2 points or a percentage figure. That's a rather crude and arbitrary method.

The seocond, slightly more sophisticated option is based on my empirical study that we are better off taking only those swing trades where the entry point is not above the last swing high (for longs). This is better but has two main problems. First, I'd miss trades that occur after small downswings and where the up bar, although not a wide bar itself, breaks the last swing high (but this I can live with). Second, in downswings where the bars have wide ranges, the first up bar following the swing low can be below the last swing high (thus getting us into the trade), but it can still be a huge bar itself, representing an unacceptable amount of risk.

The third option is based on ATR, and it runs something like this:
At the end of every day, we'll collect the true range value of every single 1min bar occurring in what I consider the core trading period (1000-1200 and 1400-1530 ET). We then plot them and decide the most likely range of a 1min bar. One can do this by simply calculating the interval in which, say, 95% of the values are. Our maximum risk will be a function of the upper limit of this interval. Simple interval estimation.

So I think it's going to be a mixture of option 2 and 3.

PS: Or I could opt for a simple life and just calculate the ATR of all 1min bars of the last trading day, across the entire day, then use this number as the starting point of calculating the maximum risk.
 
Last edited:
Updates on the entry criteria with reference to trend:

We'll consider a long swing trade when either of the following is true:
- The 15-period triangular moving average is not-declining. If it is flat, its last direction was up.
- The 15-period triangular moving average is declining, but it was up no more than 5 bars back, and we have a higher swing high.

The rationale is obvious. The moving average is not the absolute measure of trend. The market can go through a slightly more than average correction, bringing the MA down, but we should give the market benefits of the doubt as long as the price acts right.
 
Last edited:
Does anyone know of a trading software with

End of day feed for worldwide stocks and futures
Delayed intra-day feed for worldwide stocks and futures
Low price
Offline usability (not mandatory)
Good programming capability
 
Last edited:
ProRealTime : Real Time Technical Analysis Software

I recomend this one its free for EOD, has world wide stocks and futures and programmable.

if you then open an IG spreadbet account similar data is available intraday for a lot of the stocks and futures. on a very similar platform from the same charting company.

hope that helps you a little

good luck again, a very good and interesting journal ...keep it going (y)
 
if your definition of trend encompasses several dozen bars, bailing out after one down bar after entry seems like reacting to noise. it could be a spurious, narrow, sideways breather before the move proper gets underway.

Having thought about this, your comments makes sense, but also I think the bar immediately closing at the lows tells us something, possibly. So instead of tightening the stop for the entire position, I may tighten the stop for one unit, or exit one unit.

The following statement is therefore removed from the trading plan for the time being, pending further study.

"If the bar immediately following entry (i.e. the bar that breaks the high of the swing low bar and get us into the trade) closes in the bottom half, the stop for the entire position will be tightened to below that bar."
 
...which complicates our trade management scheme slightly. If we have exited one unit early, how do we handle our remaining 2 positions? Our current management plan assumes we have all 3 positions, so we need to decide the order of precedence of the management rules.
 
Modified management rules to handle early exits.

Each unit has normal stop rules and early exit rules.

On entry, the position for all the stops is below the swing low.

Unit 1:
If the first bar following entry closes in the lower half, then move the stop below that bar.
If we get stopped out, fine. If we don't get stopped out but the next bar also closes in the bottom half (that's two bars in a row immediately following entry), we close this unit.
If the early exit rules don't kick in, the stop remains below the swing low, until we have 3 up bars in a row at which point we close this unit.

Unit 2:
If two consecutive bars following entry close in the bottom half, then move the stop below the second such bar. Note that by this time the first unit will have been closed. If we don't get stopped out but the next bar also closes in the bottom half (that's three bars in a row immediately following entry), we close this unit.
If the early exit rules don't kick in, the stop remains below the swing low, until we have 3 up bars in a row, at which point we start trailing this stop below the 3-bar low.

Unit 3:
If the first two units have been closed following early exit rules, then move this unit below the low of the current bar (if that is higher than the swing low, where it initially is).
If the early exit rules don't kick in, this unit is trailed below swing lows.

That's enough for now. I intend to start backtesting tomorrow.

The plan going forward is as below:
- Backtest using the 1min chart of the day after market as closed.
- Modify plan as needed.
- Backtest with modified plan and attain a level of stability.
- Forward test (either by scrolling forward or playing a tick file, I haven't decided yet).
- Modify plan as needed.
- Forward test with modified plan and attain a level of stability.
- Start paper trading.
 
Top