Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

CandleStickPattern(...)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CandleStickPattern(...)

    The NT default functions
    CandleStickPattern(ChartPattern.Hammer, 3).PatternFound[0]
    CandleStickPattern(ChartPattern.ShootingStar, 3).PatternFound[0]
    identify the interesting occurrence of two major candlestick patterns: the bullish Hammer and the bearish ShootingStar.
    However, there is a small problem. According to the
    candlestick theory, Hammer and Shooting Star mark a reversal: in other words, the Hammer should occur just after a downtrend and reverse it, the Shooting Star just after an uptrend, and reverse it either.
    On the contrary, the results of the above mentioned NT functions - instead of always starting countertrends -
    sometimes happen to follow the current trend direction, what would eventually identify other candlestick patterns with different names (like the Hanging Man) but not the desired ones.
    Therefore my question: do these NT functions consider the previous direction, as the red "3"
    in the brackets seems to suggest ? I feel to say they don't.
    If so, I'd be glad if someone can point out how to modify the code in order to search for reversals only.
    Thanks.

    Mauro




    Last edited by fliesen; 07-13-2014, 05:00 AM.

    #2
    Originally posted by fliesen View Post
    The NT default functions
    CandleStickPattern(ChartPattern.Hammer, 3).PatternFound[0]
    CandleStickPattern(ChartPattern.ShootingStar, 3).PatternFound[0]
    identify the interesting occurrence of two major candlestick patterns: the bullish Hammer and the bearish ShootingStar.
    However, there is a small problem. According to the
    candlestick theory, Hammer and Shooting Star mark a reversal: in other words, the Hammer should occur just after a downtrend and reverse it, the Shooting Star just after an uptrend, and reverse it either.
    On the contrary, the results of the above mentioned NT functions - instead of always starting countertrends -
    sometimes happen to follow the current trend direction, what would eventually identify other candlestick patterns with different names (like the Hanging Man) but not the desired ones.
    Therefore my question: do these NT functions consider the previous direction, as the red "3"
    in the brackets seems to suggest ? I feel to say they don't.
    If so, I'd be glad if someone can point out how to modify the code in order to search for reversals only.
    Thanks.

    Mauro




    You are confusing causality with correlation.

    The fact that a pattern such as a hammer has been made after a downtrend does not mean that the market MUST reverse: it has just apparently been shown to do so quite often. The market will do what the market will do. You (or NT, or anyone) identifying a particular pattern has nothing to do with what the market will do. The market, many times, confounds any signal. That is why one must trade on the assumption that one can be in the wrong position. Hence, a Stop Loss order.

    Appropos of nothing, in any case, many so-called reversal signals, when backtested statistically have been shown to be nothing more than 50/50 propositions in reality. Bulkowski's tests show that both of the patterns that you have asked about succeed only about 60% of the time. That is statistically significant, but still far from certainty. And yes, NT does take trend into account: read the code and you will see how.

    ref:
    This article describes the hammer candlestick, including performance statistics and rankings, written by internationally known author and trader Thomas Bulkowski.

    Article describes the shooting star candlestick, including performance statistics and rankings. Written by internationally known author and trader Thomas Bulkowski.

    Comment


      #3
      Hello fliesen,

      Thank you for your post.

      The trendStrength looks to the strength of the trend to the left and right of the bar, this however, does not and cannot look forward past the last bar. It will calculate based on the closed bars, and as Koganam pointed out is no guarantee of the coming trend.

      Comment


        #4
        Maybe I was not able to clarify myself.
        I'm not saying that a trend MUST occur in the market just because of an indicator (as any trader knows since his very start).
        I'm saying that both NT functions signalize a pattern when they SHOULD NOT -> namely a bullish Hammer after an uptrend, and a Shooting Star after a downtrend, (this is what I meant by "following the direction"); therefore I wonder if those functions have regard for the important condition of the previous direction (that should be the opposite one).
        Last edited by fliesen; 07-14-2014, 02:01 AM.

        Comment


          #5
          Thanks. This confirms my feeling that the NT functions do consider the strength but not the direction of the previous bars.
          In my opinion, as far as a pattern strictly requires a condition, it may be confusing to totally disregard it.
          In any case, would a simple

          if (Close[0] < Close[1] && Close[1] < Close[2] && Close[2] < Close[3])

          filter more correct results (for the bullish Hammer pattern) ?

          Comment


            #6
            Hello fliesen,

            Thank you for your response.

            I would recommend reviewing the code for the Hammer (or InvertedHammer) CandleStickPattern (under Tools > Edit NinjaScript > Indicator). If this is not what you expect to determine a Hammer, you can implement your own logic in your indicator and/or strategy.

            Comment


              #7
              In your post you were skeptical about patterns that "succeed only about 60% of the time".
              With the correct management, 60% is a percentage that already allows good profits.




              Or do you have something that gets to 80-90% ?
              Thanks for sharing.......

              Comment


                #8
                Originally posted by Mauripasto View Post
                In your post you were skeptical about patterns that "succeed only about 60% of the time".
                With the correct management, 60% is a percentage that already allows good profits.




                Or do you have something that gets to 80-90% ?
                Thanks for sharing.......
                No, I was not skeptical at all. 60% is in the realm of "better than really good". As you say, money management is the far more important aspect.

                I was merely pointing out that 60% is far from certainty. It means that 40% of the time, there will be a downtrend followed by a hammer, which will be marked as such, and the market will continue down anyway. As the software does not know the future, it is not reasonable to expect the hammer not to have been so marked. At the time that it was marked, there was a 40% chance that it was not a reversal, but the software has no means of determining which ones are not going to fail after being marked.

                The alternative is to remove any that prove to have failed to be reversals. That is even worse, as it paints a picture that now has no relation to reality, and creates a (false) 100% rosy picture. Unfortunately, that seemed to be the criticism that I was reading: that many of the patterns marked by the indicator turned out to be failures, and, therefore, it was the indicator that marked them wrongly. I was merely pointing out that that expectation was unrealistic, given that backtests show that 40% of that particular reversal signal have failed, even when measured with perfect foreknowledge of the future, which after all, is all that a backtest is in reality.

                Comment


                  #9
                  Once again, nobody expects signs of certainty in the stock market; and neither do I.
                  I expect - yes - a software not to be wrongly implemented. Each pattern has its assumptions: if a code simply disregards them, or sets incorrect / partial conditions when looking for a Hammer (or whatever) before its occurrence, you can't blame market uncertainty.

                  Comment


                    #10
                    Originally posted by fliesen View Post
                    Once again, nobody expects signs of certainty in the stock market; and neither do I.
                    I expect - yes - a software not to be wrongly implemented. Each pattern has its assumptions: if a code simply disregards them, or sets incorrect / partial conditions when looking for a Hammer (or whatever) before its occurrence, you can't blame market uncertainty.
                    My statement is pretty simple. At the time that the pattern was marked, it was the last bar in the pattern and was correctly marked. If subsequent bars show do not conform to what the pattern supposedly portends, it does not mean that the pattern was incorrectly identified: it means that the pattern failed, not the software that marked the pattern that was correct at the time that it was marked.

                    Maybe you can show an example of a hammer that was not correctly marked? IOW, a hammer where the bars BEFORE the hammer did not show a downtrend in place, regardless of whether the downtrend continued or there was a reversal.
                    Last edited by koganam; 03-07-2017, 07:13 AM. Reason: Corrected punctuation and spacing.

                    Comment


                      #11
                      At the time that the pattern was marked, it was (definitely) not correctly marked according to the commom candlestick theory, which for a hammer requires, all together,
                      1) the previous condition of a trend;
                      2) the searched pattern, and - you won't believe it
                      3) even an initial confirmation of the reversal in the next coming period.
                      Nothing more than a probabilistic theory that may well fail, but it surely makes no sense to talk about, if a NT software function and a person completely or partially ignore it.
                      I feel in the meanwhile we exausted the audience's interest on the matter.
                      Last edited by fliesen; 07-16-2014, 05:43 AM.

                      Comment


                        #12
                        Originally posted by fliesen View Post
                        At the time that the pattern was marked, it was (definitely) not correctly marked according to the commom candlestick theory, which for a hammer requires, all together,
                        1) the previous condition of a trend;
                        2) the searched pattern, and - you won't believe it
                        3) even an initial confirmation of the reversal in the next coming period.
                        Nothing more than a probabilistic theory that may well fail, but it surely makes no sense to talk about, if a NT software function and a person completely or partially ignore it.
                        I feel in the meanwhile we exausted the audience's interest on the matter.
                        I agree those are the conditions. Now can we see an example of when such happens? Because, if it is wrong, then it needs to be corrected.

                        Comment


                          #13
                          Hey,guys,

                          what is the formula for the reverse ShootingStar?

                          by default i can see only bearish ShootingStar formula:

                          (High[0] > Open[0] && (High[0] - Open[0]) >= 2 * (Open[0] - Close[0]) && Close[0] < Open[0] && (Close[0] - Low[0]) <= 2 * TickSize)

                          Comment


                            #14
                            Hello outsource,

                            Thank you for your post.

                            The opposite is not implemented in the CandlestickPattern indicator. You could create your own indicator to check for the opposite pattern of the Shooting Star.

                            Please let me know if you have any questions.

                            Comment


                              #15
                              Originally posted by NinjaTrader_PatrickH View Post
                              Hello outsource,

                              Thank you for your post.

                              The opposite is not implemented in the CandlestickPattern indicator. You could create your own indicator to check for the opposite pattern of the Shooting Star.

                              Please let me know if you have any questions.
                              Could you post the opposite formula?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Gerik, Today, 09:40 AM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by RookieTrader, Today, 09:37 AM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by alifarahani, Today, 09:40 AM
                              0 responses
                              5 views
                              0 likes
                              Last Post alifarahani  
                              Started by KennyK, 05-29-2017, 02:02 AM
                              3 responses
                              1,285 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              11 responses
                              186 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X