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 CarlTrading, 03-31-2026, 09:41 PM
                  1 response
                  64 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by CarlTrading, 04-01-2026, 02:41 AM
                  0 responses
                  35 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CaptainJack, 03-31-2026, 11:44 PM
                  0 responses
                  59 views
                  1 like
                  Last Post CaptainJack  
                  Started by CarlTrading, 03-30-2026, 11:51 AM
                  0 responses
                  62 views
                  0 likes
                  Last Post CarlTrading  
                  Started by CarlTrading, 03-30-2026, 11:48 AM
                  0 responses
                  51 views
                  0 likes
                  Last Post CarlTrading  
                  Working...
                  X