• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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));
            	      {
            			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 n8dogg59, Today, 03:07 PM
                0 responses
                1 view
                0 likes
                Last Post n8dogg59  
                Started by Newtrader101, Today, 10:31 AM
                1 response
                16 views
                0 likes
                Last Post koganam
                by koganam
                 
                Started by nepenthean, Today, 12:36 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_ChrisL  
                Started by sun0781, Yesterday, 05:02 PM
                1 response
                24 views
                0 likes
                Last Post NinjaTrader_ChrisL  
                Started by Emma1, Today, 12:14 PM
                1 response
                4 views
                0 likes
                Last Post NinjaTrader_ChrisL  
                Working...
                X