Buy when SP500 makes new high and IBS is low strategy

Forums ProRealTime English forum ProOrder support Buy when SP500 makes new high and IBS is low strategy

Viewing 15 posts - 1 through 15 (of 20 total)
  • #73756

    A certain someone kindly shared a link with me and asked me if I would test it out and post my thoughts here. Below is my initial testing which along with the strategy I post here for further discussion.

    The link sent to me:

    http://jonathankinlay.com/2018/06/simple-momentum-strategy/

    and the strategy details are here:

    http://www.quantifiedstrategies.com/buy-when-sp-500-makes-new-intraday-high/

    Thank you to the original authors for publishing this idea.

    Basically it is an SP500 daily long only strategy that buys if the bars high is higher than the last five bars highest highs and the bars close is within the bottom 15% of the bars range. There is also some time criteria based on Chicago hours but for my initial test I chose to ignore this. That is something for when MTF is released I think!

    So the very simple strategy that I coded was this:

    Screenshot_2-3

    Not too bad, although there hasn’t really been any profit since the end of 2015 and performance was terrible prior to 2001. Sometimes you should expect to see this in a strategy as computer based trading only really started to take off around then.

    So as it is such a simple strategy analysis of the two main variables is very easy to do so next thing I thought that I would play with the entry level for the inner bar strength.

    Screenshot_3-6

    Ignoring the very low values below  0.04 (4% of the bars range) as there is not much data so it can get a bit skewed – it is nice to see that by making our entry criteria tighter we reduce trade quantity but increase our return per trade. This proves that the inner bar strength as a condition is working as it should in this strategy.

    Next was to fix inner bar strength level at the authors original 0.15 (15%) and see what happens if you change the look back period for the high higher than p bars highs.

    I tested values from 2 (just looking at the last bar) through to 100. It seemed a good idea to graph the results in Excel to more easily visualise them.

    Screenshot_4-2
    Screenshot_5-3

    The percentage of wins and average gain per trade charts are a little bit lumpy and bumpy but not too bad. It seems that five is not a bad value but there may be some merit in reducing this to increase the number of trades and the overall total gain.

    So I decided to settle on the value with the most trades 2 and then see how changing the inner bar strength level looked in charts.

    Screenshot_6-1
    Screenshot_7

    Interestingly the win rate is pretty level across the range. Obviously the lower the IBS level the fewer the trades. There seems to be a good average gain per trade the lower the IBS level is set but once again under 5% has too little data to be useful for analysis. Between 15% and 19% has the largest overall gain so if we settle for 17% what do the results look like.

    Screenshot_8-1
    Screenshot_9

    The black line is an equity curve where 1 is deducted from the strategy profit whenever a position is held overnight. Worryingly it seems that since early 2013 overnight fees may just be sucking the life out of the strategy.

    Plenty more testing to be done and ideas to be tested. I did look at the same strategy on the DJI index and it worked well there with a look back period of around 15 bars.

    Please post here your thoughts, ideas and further tests and remember that this is not my strategy idea and I am not recommending anyone to trade this with real money just yet!

     

    1 user thanked author for this post.
    #73767

    Hi Vonasi, I’m glad you liked the link 🙂 You made a very good job with your analysis, hopefully some people will join the IBS ride with us!

    Internal Bar Strength related strategies also available on our website: (classic mean reversion theory)

    RSI and IBS based EA

    Internal bar strength QQQ strategy

    Internal Bar Strength Gold XAUUSD 2 hours TIMEFRAME

    Some periods are more relevant for mean reversion strategies, I remember had came across a math study to know if it is time or not to trade them, I’ll try to get my hands on it.

    #73769

    Thanks Nicolas. Still plenty to be analysed and tested.

    One thought was that a lower IBS gives more gain per trade but happens less often maybe position size adjusted according to IBS level might be beneficial.

    Also my tests on the DJI seemed to indicate that it might be a better market to focus on initially.

     

    #73781

    So I tried to get the profit back on the SP500 while using settings of 2 and 0.17 but nothing helped so I decided to switch the exact same strategy on to the DJI and see how it performed. I reduced the stake to the 0.5 minimum size for the DJI and left the overnight fees deduction at 1 as this is what my calculator tells me is the current overnight fees for that position size. I increased the spread from the 0.6 I used for SP500 to 2.4 for the DJI

    Screenshot_12

    It works surprisingly well straight out of the box although the 2000 onwards recession was not a good time for the strategy.Strangely it coped very well in the 2008 recession though. Maybe a simple recession filter would benefit – maybe the 12:1 filter or average line penetration filter or a simple moving average filter but then we start to get into new levels of curve fitting with an extra condition to consider. Maybe only trading when the equity is above an average of the equity line would work although I have not found this to be such a great idea so far as you still need to curve fit an average line along with the disadvantages of the associated lag.

    What is good to see is that the adjusted black equity line is now showing a nice slope upwards since the beginning of 2003. That makes me want to double check that my spread and overnight fees are set correctly for this market before I continue!

     

    #73790

    I have been trying out various filters:

    Close is greater than close n candles back.

    Close is greater than average of n closes.

    Penetration filter with various settings for average and look back.

    12: 1 filter and other ratios.

    ….and nothing really lit any fires so I gave up.

    I then decided to add one extra entry condition and bingo! A beautiful equity curve through recessions and all.

    Screenshot_13

    Now it is your job to work out what extra condition needs to be met for entry!

     

    #73798

    It looks that good you must have deselected the tick by tick box!!?? 🙂

    #73799

    I graphed my extra condition with a range of values to check how fitted it is:

    Screenshot_14
    Screenshot_15

    I’m pretty happy that it isn’t over fitted – but oh how I wished that PRT could produce these graphs for me rather than having to mess around in Excel. Graphs of draw down and other analysis ratios would be fantastic too.

    #73803

    It looks that good you must have deselected the tick by tick box!!?? 🙂

    Tick by tick deselected for all tests as it is an end of day strategy. So no prize for you then!

    1 user thanked author for this post.
    #73807

    …and so just for fun I added my simple money management code. I doubled the stake to 1 as the money management works better with this starting point ona 10K starting bank. I also eased my entry criteria for the new condition quite considerably which creates more trades at the cost of a slightly rougher ride on the equity curve. I also turned on slightly my increasing risk as profits increase to accelerate growth (very risky idea)…. and here is the result since beginning of 2000:

    Screenshot_16

    Over 43K in 17 and a half years. Not too shoddy. Now I will turn the money management off and stop dreaming and keep on testing!

    #73880

    So I spent the night having nightmares about uncontrollable draw down which can happen when you write a code with no stops. I like trading with no stops and just exiting on an indicator condition or two but it is always good to know what your risk is.

    So as this strategy only exits a trade if the close is greater than the last high I decided to see what was the average was and the longest run of candles was without this condition being met on the DJI daily.

    So I wrote this simple indicator:

    and the results were this:

    Screenshot_1-10

    So the average number of days without a close greater than the last close is 3.007 so that is pretty good but the longest run is 34 days and that is a long time to be watching the market fail to close higher. So maybe I need to test the strategy by adding a condition to sell if the run of candles without a new high is a certain amount over the average and see how that affects things.

    I also have an idea regarding position sizing that I want to try out.

    Plenty more testing and analysis yet to do…..

    Hopefully someone out there is enjoying this journey of testing and analysing this strategy – please feel free to jump in with any ideas, developments or test results!

    #73891

    So I built the average number of bars without a close greater than the last high average calculation into the strategy and ran an optimization test with a new exit condition to sell if the number of bars without a close greater than the last high is more than the average +1 to 34 days.

    I graphed the results in Excel for clarity:

    Screenshot_3-7

    Screenshot_4-3

    So it seems that anything beyond holding a position more than 14 days over the average is not really worthwhile and also that cutting trades short too early can seriously effect overall gain. I decided to record the results taking into account the deduction of overnight fees of 1 for every night a position is held: Here is the graph:

    Screenshot_5-4

    So it definitely seems that historically 14 days over the average has been the optimal time to give up on a trade. Holding any longer than that and overnight fees have actually reduced your total gain.

    I am not a fan of time based exits because they are so easy to curve fit but sometimes it is sensible to give up on a trade that has not hit your target after a certain amount of time.

    Here is the equity chart for selling if a trade hits 14 days over the average:

    Screenshot_7-1

    1 user thanked author for this post.
    #73898

    IMO position sizing would come after your filtering criteria because it could affect the profitability and tend to say that the strategy is OK (because of nice profit) while it is not really..

    Vonasi wrote:

    So I spent the night having nightmares about uncontrollable draw down

    Welcome to my world 😆

    1 user thanked author for this post.
    #73899

    IMO position sizing would come after your filtering criteria because it could affect the profitability and tend to say that the strategy is OK

    Yes – I have had a little play with position sizing just because I was curious but I have put it in an IF PosSizing THEN ENDIF so that I can just turn it off while I test the strategy with level stakes. I always do all my testing with level stakes and then position size adjustment and money management are only turned on once I am 100% happy with the strategy.

    #73902

    On the subject of adjustable position sizing based on the output of an indicator I would add that I would only ever consider using it if there was a strong correlation between the value and the probability of a winning trade or the value and the probability of a greater return.

    For example you have an indicator that returns a value from 1 to 50 and your testing has confirmed that when the value is 1 you have a 100% chance of a winning trade (but very few trades) and when the value is 50 you have a 75% chance of a winning trade (but lots of trades) and a line drawn through the % of all values in between goes straight from 100% to 75%. I would then consider staking more on a value of 1 than on a value of 50 and adjust stakes in between increasing or decreasing based on the probability.

    1 user thanked author for this post.
    #73909

    Just for fun….. here is the the same strategy with the indicator adjusted position sizing turned on, money management also turned on and increased risk with increasing profits turned slightly on.

    99K since the beginning of 2000. Now I’ll switch it all back off and try not to get too over excited about the possibilities when I haven’t even started forward testing it at level stakes yet.

    Screenshot_8-2

    2 users thanked author for this post.
Viewing 15 posts - 1 through 15 (of 20 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login