Jump to content

# 3 Day Trend and Hull Moving Average

## Recommended Posts

I have been working on a new algorithm for the better sense of the word, I have been playing with some ideas and here is what I have come up with. It's come up with some profitable results so far so I wanted to get your thoughts.

• Take the price for the last 10 days and calculate the Hull Moving Average. The benefit of the Hull moving average is that it cuts out a lot of noise.
• Take the last 3 days close price and check that if it has been all up or all down.
• If the the current price is above the HMA then buy and if it's not sell (All days up) the idea being that it's breaking to the upside or trend reversal if not.
• If the the current price is above the HMA then buy and if it's not sell (All days down)

I currently have the take profit (limit) set at 2% of the current price, I can't figure out a better way of deciding where to set the take profit (in pips)? Anyone got any good Python functions or modules that would let me work that out?

I have a fully working Python algorithm that works with the IG Index API trading on UK stocks if anyone is interested?

• 1
• 1
##### Link to comment

Hi,

This sounds pretty interesting. What are you applying it to? Individual stocks?  Just curious to know,.
I have a couple of ideas, but first, I wonder if there is a typo there, because on your second main bullet, you address "if the current price is above the HMA and if it's not sell" which reads exactly the same as the first bullet, except that you then have (all days up) in one and (all days down) in the other. I don't quite follow. Should one of those sells say buy?

My suggestion for where to set stops would be to link it to some measure of ATR (average true range), perhaps setting this to a 10-day ATR, since the data you're using reaches back as far as 10 days also. This will give a time-varying sense of how much potential the price has (based on the very recent past) to move a given amount. Setting a purely numerical absolute level such as 2% could have wildly different propensities to cut your losses early in different market conditions.

Depending if I'm reading it correctly, this seems to be a trading rule that is based around trending and momentum. It can be more helpful to focus in these cases on having a stop loss to minimise downside when a position has been opened and once again that ATR indicator is useful for that, since you need to give a trade a little more room to breathe when average range per period is higher. You can then (if the trade gains sufficiently) shift up your stop loss, keeping it a certain distance below spot so there's still room for the trade to breathe without cutting you out too prematurely. Ideally your trade goes into profit enough that you can bring your stop loss up to breakeven or higher so after that, the trade cannot possibly lose money.

However, it doesn't usually doesn't pay to restrict your upside when trading trends / momentum. Rather than a mechanically derived take-profit level decided at the outset, you might want to keep a trade running if it's still making money which means that the underlying trend is still going, until there is some sign of the trend starting to weaken. You'll never get the full benefit of trend based trading if you reduce the opportunity for your winning trades to become big winners. This is easy enough to build into the rule.

You could have several things that ultimately close your trade and just one of them coming true could be enough to trigger closure. One of them could be in relation to passing below a particular moving average (a shorter one than 10 days, in order to be responsive to deterioration in the trend); another could relate to consecutive days move in the underlying price - in other words some adjusted version of the conditions you used to enter the trade in the first place.

Or you could measure drawdown from the highest point the P&L of the position reached so far. Let's say the trade reached a peak P&L of 10% and then began to drift, and rather than waiting for it to turn upwards again you could ask: (a) have at least 3 days passed without the trade making a new high? (b) has the P&L declined by at least 3% from its high? (this is somewhat similar in nature to having a moving stop loss which you have shifted upwards each period that the trade has gained), and if at least one of these questions is answered YES then close.

There are so many methods but the key is whether a thorough backtest (including out of sample performance) works in a consistent enough way. Also beware of the fact that with many asset price series there's an asymmetry between the behaviour of their upside trends and their downside trends.

Hope this helps!

• 1
##### Link to comment

Thanks for your detailed reply. Yeah so I have updated it a bit this is the table of how I see the trades working. I am applying this to stocks.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

## Sign in

Already have an account? Sign in here.

Sign In Now
• ### General Statistics

• Total Topics
21,299
• Total Posts
90,951
• Total Members
41,432
• Most Online
7,522
10/06/21 10:53

Newest Member

Joined 08/02/23 12:30
• ### Posts

• EURUSD, GBPUSD and AUDUSD prices oversold in uptrend Volatile trade, following Fed Chair Jerome Powell’s comments at the Economic Club of Washington DC, has ultimately ended in gains for major US indices and some minor losses for the US dollar. Source IG   Forex United States dollar EUR/USD Euro AUD/USD GBP/USD  Shaun Murison | Senior Market Analyst, Johannesburg | Publication date: Wednesday 08 February 2023 Acknowledgement from the Fed chair, that the disinflation process had begun, might have provided some excuse for a softer dollar, although there was also a suggestion from Jerome Powell that rates could rise further than markets are currently pricing in if inflation starts to rise again. Markets appeared to dismiss the ‘hawkish’ comments from the Fed, and major benchmark indices have started to extend the bullish trends we have seen this year, while the dollar has paused gains (for now at least). EUR/USD Source IG The moving 20 (red), 50 (green) and 200 (blue) day simple moving averages (MAs) reaffirm the upward trend bias for the EUR/USD. The stochastic oscillator currently trades in oversold territory whilst displaying a positive divergence (dotted red lines) with the price. The technical indications for the EUR/USD remain bullish for the time being. The recent retracement in price looks to have found support at the 50MA and 1.0707 support level. We are looking for a strong close on today’s (8 February 2023) candle. In this scenario 1.1035 becomes the initial upside resistance target from the move, while a close below the low at 1.0670 might be used as a stop loss indication for the trade should it manifest. GBP/USD   Source IG The GBP/USD currently trades in a short to medium term rangebound environment, although the longer term trend is still considered up. The price looks to be forming a bullish price reversal from oversold territory, whilst also displaying a bullish divergence (dotted red lines). The bullish indications suggest a possible range trade opportunity forming. Confirmation thereto would be a strong close on today’s candle. In this scenario, 1.2440 becomes the initial resistance target from the move, while traders might consider using a close below the 1.1850 level as a stop loss indication for the trade (should it manifest). AUD/USD   Source IG The AUD/USD is trading similarly to the EUR/USD currently. The moving 20 (red), 50 (green) and 200 (blue) day simple moving averages (MAs) reaffirm the upward trend bias for the currency pair, while the stochastic oscillator trades through oversold territory (although not displaying a bullish divergence as with the EUR/USD). The technical indications for the AUD/USD remain bullish for the time being. The recent retracement in price looks to have found support at the 50MA and started to reverse off this level. 0.7155 becomes the initial upside resistance target form the move, while a close below the low at 0.6853 might be used as a stop loss indication for the trade.
• Did Powell cap interest rate expectations and in turn revive the Dow and other risk benchmarks? More likely, fed rate expectations fueled by last week’s strong data run has likely find a natural equilibrium; but that means risk trends and the Dollar need a new guiding fundamental light to render tentative breaks into viable trends.
• I don't think the IG spreadsheet is supported anymore and like you have discovered it is tricky and time-consuming to get working. I've lots of experience using Excel for financial markets/trading purposes as well as using the IG API. I've built an Excel Add-in which makes using Excel with IG much easier, you don't need to deal with DDE, RTD etc. you can just use standard Excel formulas: https://www.excelpricefeed.com/ I think Excel is great for analysing prices, backtesting, modelling, generating signales etc. but I would not suggest that you try to use it for actual trading. Andy
×
×
• Create New...