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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    57 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    143 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    161 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    97 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X