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

Darvas Box Buy / Sell Signal

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

    Darvas Box Buy / Sell Signal

    I'm a newbie to NinjaScript development. I'd like to draw an arrow when there is a buy signal or a down arrow when there is a sell signal for Darvas box in order to add clarity to this indicator. What do you think if I try something like below?

    // today buy/sell signal is triggered
    if ((state == 5 && currentBarHigh > boxTop) || (state == 5 && currentBarLow < boxBottom))
    {
    if (state == 5 && currentBarHigh > boxTop)
    {
    BuySignal = true;
    DrawArrowUp(CurrentBar.ToString(), true, 0, Low[0] - TickSize, Color.Green);
    }
    else
    {
    SellSignal = true;
    DrawArrowDown(CurrentBar.ToString(), true, 0, High[0] + TickSize, Color.Red);
    }

    state = 0;
    startBarActBox = CurrentBar;
    }

    Thanks very much,

    Richard

    #2
    Richard, you would need to give it a run and see if you get the results you expect, I would probably use a unique drawing id tag for long / short signals. One thing to keep in mind with the Darvas indicators is that they are more meant to be a visual trading aid and thus recalculate when conditions warrent it, so to see which values of those boxes are accessible in realtime and at what exact point in time, I would plot the Darvas.Upper[0] and Darvas.Lower[0] series in an indicator to begin with.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Drawing of Box Bottom

      Hi Bertrand,

      Thank you very much for your help. My code works. The up down arrows are plotted nicely on the chart. This helps me to manually check the validity of each box. However, I might have discovered a problem with the drawing of the box bottom.

      In two selected cases in the attached chart, I spot a box bottom is draw with only 2 high lows instead of 3 as defined by Darvas. Unless this is not a box, but there is a down arrow (based on SellSignal = true). What do you think?

      If this is a problem, I'd like to make a change myself, but I'd get your opinion first. Can you point me to the code that counts 3 higher lows?

      Thanks very much again for your help.

      Richard
      Attached Files

      Comment


        #4
        Hi Richard, sorry I'm not following you - are you saying you expect the boxes to be drawn by different rules? The code itself is open to review, be sure to expand the Misc section as well for a complete picture.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand,

          Thanks for your reply.

          As I understand the basic rules are:
          1) Box Top is formed when there are 3 lower highs.
          2) Box Bottom is formed when there are 3 higher lows.

          I notice that there is no problem with Box Tops but the Box Bottoms are sometimes formed with only 2 higher lows instead of 3 higher highs.

          I looked at the Misc section (the Case statements), but I could not figure out where in the code enforcing 3 higher lows as the condition for forming Box Bottoms is located. Can you please give me a hand?

          Thanks,

          Richard

          Comment


            #6
            Richard, perhaps this info helps explaining the states used - http://hubpages.com/hub/How-to-Trade...on-using-Excel

            I could not find reference to a static 3 HH's and 3 LL's approach you mentioned.
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hi Bertrand,

              The Darvas Box construction rules are very well documented in the Trend Trading book by Daryl Guppy, the inventor of the Guppy Multiple Moving Averages (GMMA), based on Nicholas Darvas' book on How I made $2,000,000 in the Stock Market.

              I'm quoting the Construction Rules defined in pages 337-338 of Trend Trading:
              "- The top of the Darvas Box is established when the price does not touch or penetrate a previously set new high for three consecutive days. This is essentially a four-day pattern.
              - The top of the Darvas Box always starts with a new high. This high must be followed by three days that have lower highs.
              - The Darvas Box is based on a minimum of four days of price action.

              The bottom of the Darvas Box is only calculated after the top of the Darvas Box has been confirmed. It is constructed in the opposite way to the top of the box:
              - The Darvas Box uses as its starting point the lowest low that occurs after the top of Darvas Box is established.
              - The low is followed by three days of higher lows where the price does not touch or penetrate a previously set calculation low for three consecutive days. It is again a four-day pattern, but the calculation starts with the day the top of the box pattern is confirmed,
              - This means it takes a minimum of four days for a Darvas Box to be identified for both top and bottom.
              - The top of the Darvas Box is established in four days. The bottom of the box may take much longer to establish."

              There is a special case:
              "Darvas is at times contradictory in the way he writes about the construction of the box. He appears to allow a special case when the day that sets the new high is followed by a string of inside days. In this special case he uses the initial bar set both the top and bottom of the box."

              Please take a look and let me know your thoughts. I still think the Darvas indicator sometimes did not enforce the Box bottom rule of 3 higher lowers. However, It does appear to enforce the Box top rule of 3 lower highs.

              I could not figure out by looking at the Case statements the cause of this discrepancy. Can you please give me some suggestions how to make the change myself to enforce the Darvas Box construction rules above?

              Thanks again for your help,

              Richard
              Last edited by Richard168; 06-28-2011, 06:12 AM.

              Comment


                #8
                Richard,

                NT coded the Darvas Indicator exactly according to the description in the link that Bertrand gave. Unfortunately, you and I both know that the description is not what Darvas finally disclosed in the 2nd Edition of his book: in the 1st Edition, he only talked about what he did, but did not disclose the method for drawing the boxes.

                To modify the extant indicator would require an extension of the linked description, using the same paradigm, so the short answer to your question is that there is nothing that you can simply adjust in the current indicator to draw the boxes in the manner as described by Darvas, and that you have correctly pointed out.

                If I can free some cycles, I might take a crack at writing a Darvas Box indicator according to the rules that you show, which is what Darvas wrote, in which case I shall post it. I cannot make any commitment right now though. Sorry.

                Comment


                  #9
                  Hi Koganam,

                  Thank you so much for clarifying this issue and providing your input.

                  I hope you that you or the NinjaTrader development team would invest the time someday to enhance the Darvas Box Indicator so that it will work according to the Darvas rules.

                  Thanks very much again for your interest and help.

                  Best Regards,

                  Richard

                  Comment


                    #10
                    Thanks again for the feedback provided Richard, we're tracking this enhancement suggestion to the NT Darwas box indicator now under # 1079.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_Bertrand View Post
                      Thanks again for the feedback provided Richard, we're tracking this enhancement suggestion to the NT Darwas box indicator now under # 1079.
                      It is sad that the Darvas indicator has not yet been corrected. Richard168 rightly mentions that the low end of the Darvas box is not calculated correctly. The lower end of the box is formed as the lowest bar followed by 3 higher lows. Each of the higher lows just need to be higher than the potential "lowest bar".
                      Please take a look at this interesting pdf page 43 ff.

                      Comment


                        #12
                        Originally posted by hjkrebs View Post
                        It is sad that the Darvas indicator has not yet been corrected. Richard168 rightly mentions that the low end of the Darvas box is not calculated correctly. The lower end of the box is formed as the lowest bar followed by 3 higher lows. Each of the higher lows just need to be higher than the potential "lowest bar".
                        Please take a look at this interesting pdf page 43 ff.
                        http://www.forumhub.net/darvas/Darvas-Manuscript.pdf
                        Hi Hjkrebs,

                        Thanks you so much for your support of this issue and attaching the Darvas Manuscript.

                        I hope that NinjaTrader will correct the code as soon as possible to reflect the proper way of drawing Darvas Boxes because the current code generates signals inconsistent with the original Darvas Box. It would be even nicer if they could also incorporate the modern Darvas involving Ghost Boxes and Box breakout or breakdown on close.

                        Bertrand, please kindly provide an update on the status for NinjaTrader to develop a new version of the Darvas Box indicator.

                        Thanks & Regards,

                        Richard

                        Comment


                          #13
                          Hello Richard,

                          We do not have any updates regarding item #1079 at this time.
                          MatthewNinjaTrader Product Management

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by jpapa, Today, 07:22 AM
                          1 response
                          5 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by kevinenergy, 02-17-2023, 12:42 PM
                          116 responses
                          2,758 views
                          1 like
                          Last Post kevinenergy  
                          Started by franatas, 12-04-2023, 03:43 AM
                          7 responses
                          106 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by Jltarrau, Today, 05:57 AM
                          3 responses
                          9 views
                          0 likes
                          Last Post Jltarrau  
                          Started by f.saeidi, Today, 05:56 AM
                          2 responses
                          9 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Working...
                          X