Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help with code. Please help

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

    Need help with code. Please help

    I have the following code:-

    if (((Low[0] < Low[2]) && (Low[0] < Low[3])) || ((Low[1] < Low[2]) && (Low[1] < Low[3])))
    {
    DrawArrowUp(
    "BP" + CurrentBar, true, 0, (Low[0] -(2*TickSize)), Color.Green);
    }

    I would now like to write the code for when the above condition is not present. Firstly, I would like to lock in the values of the lower of Low[2] and Low[3]. Secondly, I would like to draw an "up arrow" when the first subsequent bar to the current bar's Low is lower than the lower of Low[2] and Low[3]. Could I please have some guidance.

    #2
    Kay, you would need to assign the lower value of the two then to a variable (you can use Math.Min for the comparison).

    Not sure I follow on your second part, isn't this what you do with the posted snippet?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand,
      The second part is the same as the posted snippet but the low will be a low at some point in the future...

      Comment


        #4
        Kay, unfortunately you can't reference a price point in the future, the OnBarUpdate() will be called sequentially from the first to the rightmost bar.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand,

          Tried this:-

          double BPT = Math.Min(Low[2],Low[3]);
          if ((Low[0] < BPT) || (Low[1] < BPT))
          {
          DrawArrowUp(
          "BP" + CurrentBar, true, 0, (Low[0] -(2*TickSize)), Color.Green);
          }

          The values don't lock-in. Am I doing something wrong?

          Comment


            #6
            Any errros in the log tab? Do you have a high enough CurrentBar check at the OnBarUpdate() start to begin with?
            BertrandNinjaTrader Customer Service

            Comment


              #7
              Hi Bertrand,

              1) Yes, I should have enough bars - if CurrentBar <18 return;
              2) No errors were logged.
              3) I actually noticed something else which could be the real problem. For some reason my bar counts are limited to current trading day. Counts for the previous days do not exist. Not sure why. Would you like to take a look? There however doesn't seem to be any issue when the counts when the chart is ascending though...
              4) The 2 shaded rectangles should display counts but it isn't...

              I've attached the script.
              Attached Files

              Comment


                #8
                Kay, yes this should be enough - you would need to print out related calculation values and doublecheck they return what you expect.

                http://www.ninjatrader-support2.com/...ead.php?t=3418
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Bertrand, initially it looked great to me! then when i realised there was counting but the numbers were not being reflected prompted me. How to do I know that it is counting? Because the dashed green line and green arrow are methods that are called upon the completion of a 9-count series. What is troubling is why the numbers do not print from Day 2 onwards...They seem to be printing ok for opposing count....which I cut and pasted from the ones that are not being reflected now....

                  Comment


                    #10
                    Kay, probably the same I see here on my end, only the buy side seems to get counted, no sell side counts here on my ES charts. Best is to simplify the indicator to process one side only and then start debugging your copied together code from there...
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Believe or Not! When I go right click and select indicator and then click apply, the numbers appear!!! But when I scroll the screen left and right, they disappear again. Then I repeat the action i did above and it reappears!

                      Comment


                        #12
                        Please check into the 'Remove...' sections of the codes, there seems to be a 'cleanup' coded in to remove drawings...
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Yes, that is to remove the tags when i can't get 9 consecutive bars of similar type counts.

                          Comment


                            #14
                            Bertrand,

                            Is it possible to group each successfully completed 9-consecutive count with a unique id/tag?

                            Would you be able to point me in the right direction?

                            Comment


                              #15
                              Unfortunately not very familiar with your custom code Kay, but doubt it since for a display of all counts you need more than one tag...if you only want to plot the latest count it should be possible however...just use the same tag to 'update' those.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Virgil123, Today, 01:39 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Virgil123  
                              Started by kawalecld, Today, 12:21 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post kawalecld  
                              Started by exjayess, Today, 11:04 AM
                              1 response
                              11 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by robertlaub, Today, 11:11 AM
                              2 responses
                              7 views
                              0 likes
                              Last Post robertlaub  
                              Started by sdauteuil, Today, 10:28 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post sdauteuil  
                              Working...
                              X