Jump to content
Sign in to follow this  

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? 

  • Like 1
  • Thought provoking 1

Share this post


Link to post

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!

  • Thought provoking 1

Share this post


Link to post

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. 

 

 

Capture.PNG

Share this post


Link to post

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
Sign in to follow this  

  • Member Statistics

    • Total Topics
      12,817
    • Total Posts
      65,795
    • Total Members
      86,817
    Newest Member
    RahulD
    Joined 29/10/20 05:17
  • Posts

    • Start the conversation The US election is scheduled for Tuesday 3 November 2020, when all 50 states and Washington DC will cast their votes. The vote spans six different time zones, so the first exit polls will be available at around 11pm (EST) when West Coast voting closes. In the UK, that will be around 4am (GMT) on Wednesday 4 November 2020. The election is likely to create opportunities for traders, with price movements expected across a range of forex pairs, indices and commodities in the run-up to polling day. Volatility related to the election could continue until congress certifies the result on Wednesday 6 January 2021, or even until the winner is inaugurated on Wednesday 20 January 2021. What should traders expect to see during the US election? All US markets tend to experience increased volatility in the run up to a presidential election, including USD forex pairs, indices and commodities. That’s because many investors will attempt to lock in positions before the result is announced – using polls to gauge public sentiment. The aim is to take full advantage of the price moves that occur when the country’s political direction is confirmed. At the top level, early indications suggest that the following could be on the cards if one of these two main candidates win: Donald Trump A Trump win could see an escalation of the trade war, potentially causing problems for some US exporters and having a negative impact on the value of the dollar. However, this effect could be offset by reassurances that tax cuts and deregulation will continue – boosting the US economy. Joe Biden A Biden win could see tensions in the trade war cool, providing a boost to US exporters and the dollar. However, these effects could be offset by tax increases for high-income households, and more limited deregulation.   How will markets react to the different candidates? Market commentary by IG Senior Market Analyst Joshua Mahony Stocks Markets hate uncertainty, and historically the perception has been that a new president might bring policies that could be harmful for stocks. This happened in 2016 when analysts were confident that a Trump presidency would spark a market collapse. But, we are now seeing that same fear creep in as people consider a Biden presidency and the potential uncertainty it could cause. Biden is openly more left-leaning, and his policies are expected to be geared towards human needs rather than those of investors and traders. This sentiment isn’t helped by suggestions that Biden would reverse Trump’s tax cuts, and it is likely that markets will rise alongside the potentially increased chance of a Trump victory as we approach the election. USD The value of a currency is supposed to reflect the health of an economy and its future prospects. Many are expecting Biden to be less focused on the markets than his Republican opponent, so the dollar could weaken in the event of a Biden victory. However, this effect could be offset if Biden is able to improve relations between the US and China after years of market anxiety. In this scenario, it would be the Chinese yuan which may benefit the most, with the trade war having sparked huge upside for USD/CNH. Keep in mind that if the wider markets fall on a Biden victory – including US stocks and indices – the dollar would likely rally in the short-term to reflect a risk-off move as investors turn to USD. Gold The prospect of a more expansive fiscal policy under Biden, and from a government which is happy to embark on substantial spending programmes, could provide a boost to precious metals. There’s a caveat here too, because in the past precious metals have also followed the same patterns as the stock markets during times of crisis. So, any collapse in equity markets that may come from a change at the White House could drag gold lower in the immediate period. Plus, while Trump has finally seen the kind of stimulus he would have hoped for, a Biden win could result in a more substantial stimulus package if the Democrats gain a foothold in Congress.   How are you trading?
    • Dax has been volatile today. Down 600, Dax down 4% on COVID fears. US open in 10 minutes. 
    • Hi, Can you please advise when is the last day to buy more TILS before settlement takes place? HL platform confirmed it is 30th October, can you please confirm the same? Thanks
×
×