Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

If Else statment not working

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

    If Else statment not working

    I am trying to see if the current bar low price is lower than a preset variable.

    Here is part of the code:

    Code:
    protected void checkForLowHighSwing(double SetL1Point){
    			double L1Point = 9999.00;
    			int foundAt = 0;
    			int p;
    
    			if(all[all.Count-1].Type == "low"){
    				p = all[all.Count-1].Bar;
    			} else {
    				p = all[all.Count-2].Bar;
    			}
    			
    			if((Bars.GetLow(Bars.Count-1) - SetL1Point) <= 0.00){
    				Print("SetL1Point: "+SetL1Point);
    				Print("Current Bar Low: "+Bars.GetLow(Bars.Count-1));
    				Print("Math: "+Bars.GetLow(Bars.Count-1)+" - "+SetL1Point+" = "+(Bars.GetLow(Bars.Count-1) - SetL1Point));
    				Print("Lower - Break");
    				breakLHswing = true;
    			
    			} else {	
    				
    					Print("SetL1Point: "+SetL1Point);
    					Print("Current Bar Low: "+Bars.GetLow(Bars.Count-1));
    					Print("Math: "+Bars.GetLow(Bars.Count-1)+" - "+SetL1Point+" = "+(Bars.GetLow(Bars.Count-1) - SetL1Point));
    					Print("Not Lower - No Break");
    
                            }
    }
    Here is the output

    SetL1Point: 1876.25
    Current Bar Low: 1876
    Math: 1876 - 1876.25 = -0.25
    Not Lower - No Break

    the print out is saying that -0.25 is not <= 0................


    Any Help is much appreciated

    #2
    I am an idiot. i was setting the double incorrectly.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    647 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    369 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    108 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    572 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    573 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X