Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy on Bar condition

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

    Strategy on Bar condition

    Hello,

    I'm trying to draw a diamond below the current bar when :

    The low of the current bar is lower than the low of the previous bar
    and
    The price closes in the top half of the current bar.

    In the condition builder I designed that in the Set1 :
    Low[0]<Low[1]
    Close[0]>Median[0]

    Do the following:
    DrawDiamond("My diamond" + CurrentBar, false, 0, 0, Color.Lime)

    No diamond appear on the chart... What is the mystake ?

    Thank you for your help !
    J.

    #2
    Your draw object will only appear if your conditions are true. Please ensure that this condition is actually evaluated to true at some point in time.

    I suggest you first switch to an even simpler condition to test. Do something like Close[0] > Open[0], draw dot. When that works you will know your action is working fine. Then you can add layers of complexity onto your conditions to figure out what condition does not trigger.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      You are right, it must not be true at any moment because nothing is draw...

      Is it a problem because calculation is at bar close ?

      J.

      Comment


        #4
        Generally CalculateOnBarClose is not an issue. It will evaluate your condition at the end of the bar when you have it set to true. If that condition was not true at that moment it will not draw.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Close[0] > Open[0], draw dot
          does not work....

          Any ideas ? I'm quite lost...

          Comment


            #6
            Check your Control Center logs for errors. Add the "Print to output window" action and type a message. Next time you run please have the Output Window open and look for that message.

            Also remember you are drawing at 0. You are putting your draw object at a y-value of 0. Your instrument price is most likely nowhere near zero so it will not be in visible range of your price bars.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Ok, message is printed in the output window, but no dot on the chart....

              No particular error in the log...

              Any ideas ?

              How to make it visible, where should I draw the dot if not y=0 ?

              Comment


                #8
                Right. Like I mentioned earlier, your dot is not in the visible range of your chart that is why you don't see it. If you want to see it you would need to put the dot somewhere inside the visible range of your chart. Close[0] works well.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Ok ! I get it !!!
                  Thank you very much Josh ! Brilliant like ususally. Learning a lot with you !

                  Comment


                    #10
                    Hello,

                    Now I want to add in the condition builder, the state of an indicator.
                    For instance :
                    AO current bar is red

                    How do I do that ?

                    Thank you very much for your help !
                    J.

                    Comment


                      #11
                      Unfortunately you cannot do this in the Condition Builder due to the nature of the AO indicator.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Ok, let's forgot that for the moment.

                        Now, I want to transform my strategy in an indicator. I tried to copy what is between Variables and Properties in an indicator file, compiled it without error, but when applied on chart, nothing appear...
                        Any tips and tricks ?
                        S.

                        Comment


                          #13
                          You will want to debug as per this tip: http://www.ninjatrader-support.com/v...ead.php?t=3418

                          Check your Control Center logs for errors.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Thx Josh ! I'll do the debug process. A new thing to learn !!!

                            But is my copy/paste a good way to do ? from the strategy file to the indicator file ?

                            J.

                            Comment


                              #15
                              It could cause potential conflicts. I suggest you only copy what is within the methods. So you copy paste what is inside the OnBarUpdate() method to the indicator's OnBarUpdate() method, etc.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              651 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              577 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X