Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Invalid condition?

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

    Invalid condition?

    Hi
    I seem to have a problem with one of my conditions…

    If DonchianChannel(14).Upper[0] - DonchianChannel(14).Lower[0] > 10


    For some reason this does not work, but everything else does in the script without any error in the log.
    Is this an invalid condition or have I written something wrong?

    Thanks in advance

    #2
    What does not work?

    - Does not compile?
    - Condition never is true?
    RayNinjaTrader Customer Service

    Comment


      #3
      Yes it does compile and it does run, however the condition is always true, even if the difference of the DC is less than 10

      Comment


        #4
        I don't think this is possible. You will have to debug to see what is happening.

        For example:

        Code:
        double difference = [FONT=Arial]DonchianChannel(14).Upper[0] - DonchianChannel(14).Lower[0];[/FONT]
        [FONT=Arial]Print("Difference before condition " + difference);[/FONT]
        [FONT=Arial]if (difference > 10) Print("Difference after condition " + difference);[/FONT]
        [FONT=Arial][/FONT]
        RayNinjaTrader Customer Service

        Comment


          #5
          so are you saying that this condition should work?

          Is it important to Add this in Initialize()?

          Comment


            #6
            Yes, it will work and the code snippet I provided would be a debug test so that you could verify it. This will not work in Initialize(), you need to check for this in OnBarUpdate().
            RayNinjaTrader Customer Service

            Comment


              #7
              Thanks for your help...

              Comment


                #8
                Ray, I found the problem, I should have been looking at DC 1 bar ago not the current bar.... I think... just testing it now....

                Thanks again for your help

                Comment


                  #9
                  Great, thanks for reporting.
                  RayNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  566 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  330 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  547 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  548 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X