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

if statement evaluated when false, HELP.

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

    if statement evaluated when false, HELP.

    I am trying to understand why an if statement is getting processed even tho it is false, I have walked thru the code in Microsoft Visual Studio and have confirmed that the values are false,

    here is the code:-

    Code:
     if((highTest - lowTest) < (softSpotRange * TickSize)) 
    	{
    	highTest = Math.Round(highTest - 1 * TickSize,2,MidpointRounding.AwayFromZero);
    	lowTest  = Low[0];
    	a=2; //retest full range
    												
    	      if((highTest - lowTest) < (softSpotRange * TickSize));
    	      {
    			stopLooking = true;
    			break;
    		}
    							
    
    	}
    So when the first if statement is true highTest is reduced by 1 tick and lowTest is reset to Low[0]. The following if statement is then false but its getting processed????

    So i have no idea why this is.

    #2
    GKonheiser, it could only be processed if the condition would evaluate to 'true', there's no ambiguity here. How do you judge by it's getting processed? By your value for stopLooking being set to 'true'?
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I am stepping tho it with visual studio and it is processing inside the brackets. I have attached a screen shot. If you look at it you can see that the values equate to false but it is still looking inside the brackets???
      Attached Files

      Comment


        #4
        Is this the only location your stopLooking could be set to the 'true' value?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          No there are other places but that isn't the problem, you can see in the screenshot that the statement is false but the yellow arrow is still inside the brackets. If you step thou the code using f11 it would go inside the brackets if it wasn't processing it.

          Comment


            #6
            Originally posted by GKonheiser View Post
            I am trying to understand why an if statement is getting processed even tho it is false, I have walked thru the code in Microsoft Visual Studio and have confirmed that the values are false,

            here is the code:-

            Code:
             if((highTest - lowTest) < (softSpotRange * TickSize)) 
            	{
            	highTest = Math.Round(highTest - 1 * TickSize,2,MidpointRounding.AwayFromZero);
            	lowTest  = Low[0];
            	a=2; //retest full range
            												
            	      if((highTest - lowTest) < (softSpotRange * TickSize))[COLOR="Red"][B][SIZE="5"];[/SIZE][/B][/COLOR]
            	      {
            			stopLooking = true;
            			break;
            		}
            							
            
            	}
            So when the first if statement is true highTest is reduced by 1 tick and lowTest is reset to Low[0]. The following if statement is then false but its getting processed????

            So i have no idea why this is.
            Your "if statement" is null, because of the semi-colon that I have emphasized in red.

            Comment


              #7
              Thanks koganam, I missed that.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Your a star thx. I just didnt see that.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Aviram Y, Today, 05:29 AM
                0 responses
                5 views
                0 likes
                Last Post Aviram Y  
                Started by quantismo, 04-17-2024, 05:13 PM
                3 responses
                27 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                7 responses
                36 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cls71, Today, 04:45 AM
                0 responses
                6 views
                0 likes
                Last Post cls71
                by cls71
                 
                Started by mjairg, 07-20-2023, 11:57 PM
                3 responses
                219 views
                1 like
                Last Post PaulMohn  
                Working...
                X