Statistical Analysis of Candlesticks patterns

Discussion in 'Technical Analysis' started by AdrianHagh81, Aug 17, 2014.

  1. I don't trade the candles but am intrigued since there is a lot of literature on it

    Since a lot of guys on this forum trade the NQ, lets analyze the NQ.

    What I'm doing is loading up the NQ daily chart since 2012

    nqdailychart1.gif


    Use K means to cluster it.

    nqdailyclustergif.gif

    And lo and behold,it managed to find the common candlestick patterns all by itself, divides it into 6 clusters.
    big up bars, dojis, and hammers and etc.


    And next we find out what the correlations are.

    Cluster number is from left to right on the chart with the probabilities %
    of the next state type from a previous state shown

    1 2 3 4 5 6
    1 18.840580 2.173913 31.159420 31.884058 13.043478 2.898551
    2 19.230769 3.846154 26.923077 15.384615 30.769231 3.846154
    3 19.540230 4.597701 24.712644 39.655172 10.344828 1.149425
    4 24.369748 4.621849 24.789916 39.915966 5.042017 1.260504
    5 18.840580 1.449275 24.637681 33.333333 13.043478 8.695652
    6 12.500000 12.500000 31.250000 18.750000 25.000000 0.000000


    It seems that state 3 meaning those little red hammers tends
    to be followed by a state with an up direction.

    Will this be enough for an edge ?



    For my next post, I'm gonna do this on the NQ five minutes RTH.
     
    Last edited: Aug 17, 2014
    eusdaiki likes this.
  2. vicirek

    vicirek

    what are the input parameters characterizing bars to achieve this bar sort and why did you choose 6 as number of clusters?
     
  3. Just the OHLC data, do you have a better idea for the centroids number ?
     
  4. vicirek

    vicirek

    Choosing number of clusters is an art not science. You can just "walk" down from highest number (arbitrary choice, max would be number of samples of course) to lowest and see which looks best. Another way to check this is to use test; for example total within sum of squares for centroids or variance index to arrive at best number of clusters.

    Another important step is to scale variables because raw data can influence clustering as well due to the way distances are calculated.
     
  5. Heheh yeah "Art". Will do that. I did scale the variables though.
     
  6. Oh yeah one more conclusion by looking at the probabilities table.

    A Big Red Bar is never followed by another big red bar, so BTFD ?? at least since 2012
     
  7. vicirek

    vicirek

    In this type of analysis trend is not your friend. When you have time you can run this in choppy or downtrend markets.

    Are you using commercial tools or putting it together yourself?
     

  8. Don't you recognize the chart style ? it's just using standard R with quantmod.

    No big Red bars ever follow another big red bar, maybe a non directional
    play with options combo might be in order for the NQ on a big down day.

    Yes I'll run it on a longer time frame, but first

    I'm running it now on the 5 minutes bars since last week first to get a feel of the results
    in different timeframe.
     
    Last edited: Aug 18, 2014
    EVAP likes this.
  9. vicirek

    vicirek

    This is what I was trying to point out: big Greens do not show the same characteristics as big Reds probably because this chart is in 45 degrees uptrend. You would have to check this on something that is in downtrend and also include other chart patterns for confirmation.

    I was thinking it is R but I never used this package. I use R in regards to market data "indirectly" to have a look into data, verify, cross check etc. Thank you for reminding me about this package.

    Interestingly clustering with reconstruction of time series separated bars into "spectra" which is very interesting.
     
  10. Here is the cluster on 5 minutes on RTH only 8.30 to 15.00 hence the gap

    11 - 13 Aug 2014

    nq5mins1.jpeg nq5mins2.jpeg

    Prop table

    1 2 3 4 5 6
    1 30.000000 18.750000 27.500000 16.250000 2.500000 5.000000
    2 27.777778 16.666667 22.222222 22.222222 11.111111 0.000000
    3 41.071429 8.928571 25.000000 19.642857 1.785714 3.571429
    4 39.130435 13.043478 19.565217 15.217391 6.521739 6.521739
    5 9.090909 0.000000 27.272727 27.272727 9.090909 27.272727
    6 23.076923 38.461538 0.000000 30.769231 0.000000 7.692308
     
    #10     Aug 20, 2014