• 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 Atilla, Today, 04:05 PM
                0 responses
                10 views
                0 likes
                Last Post Atilla
                by Atilla
                 
                Started by Displacer, Today, 02:57 PM
                2 responses
                13 views
                0 likes
                Last Post Displacer  
                Started by SAILIKITY, 05-22-2019, 05:41 PM
                1 response
                9 views
                0 likes
                Last Post NinjaTrader_PaulH  
                Started by rmillar, 01-09-2019, 06:02 PM
                6 responses
                71 views
                1 like
                Last Post eDanny
                by eDanny
                 
                Started by mlarocco, Today, 11:39 AM
                4 responses
                23 views
                0 likes
                Last Post mlarocco  
                Working...
                X