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 pechtri, 06-22-2023, 02:31 AM
                9 responses
                122 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by frankthearm, 04-18-2024, 09:08 AM
                16 responses
                65 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by habeebft, Today, 01:18 PM
                1 response
                5 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by benmarkal, Today, 12:52 PM
                2 responses
                13 views
                0 likes
                Last Post benmarkal  
                Started by f.saeidi, Today, 01:38 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X