Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with && statements in code

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

    Problem with && statements in code

    Hoping someone can help me out on this.

    Just creating a strategy and i'm getting hung up on why the code isn't functioning the way it is.

    I have a code situated like this:

    if (((AdaptiveLaguerre(iadaptlength1, 1, 2, igammasmooth1, igammasmoothmode1,
    ilperiod1, 0.38, 2).MovAvgUp[0] == AdaptiveLaguerre(iadaptlength1, 1, 2, igammasmooth1, igammasmoothmode1,ilperiod1, 0.38, 2).Laguerre[0]))
    &&
    ((AdaptiveLaguerre(iadaptlength2, 1, 2, igammasmooth2, igammasmoothmode2, ilperiod2, 0.38, 2).MovAvgUp[0] ==AdaptiveLaguerre(iadaptlength2, 1, 2, igammasmooth2, igammasmoothmode2, ilperiod2, 0.38, 2).Laguerre[0]))
    &&
    ((AdaptiveLaguerre(iadaptlength3, 1, 2, igammasmooth3, igammasmoothmode3,
    ilperiod3, 0.38, 2).MovAvgUp[0] == AdaptiveLaguerre(iadaptlength3, 1, 2, igammasmooth3, igammasmoothmode3, ilperiod3, 0.38, 2).Laguerre[0] )))
    {
    EnterLong(Sharesinplay, "Long");
    }
    Please see image
    Now it is suppose to enter long when all three are true (as in green), like it did with the short (red). However when it entered long, only 2 out of 3 laguerres were green and it still thought it should go long, when as you can see in the code, to go long, all three laguerres have to be true.

    I believe the code is not resetting on every Barupdate. How can reset the laguerre's so on each barupdate it looks for the parameters on just the previous bar? Isn't the code I have suppose to do that already? Any information would be greatly appreciated!!

    Hope that makes sense.
    Attached Files

    #2
    The logic looks okay at a glance.

    Is your strategy running on CalculateOnBarsClosed True or False? What is your chart set to?

    At this point, I would open the NT output window in in command center under tools,
    and put in 3 Print statements in your code, printing out each value.

    You will see exactly what each value is, and probably see that each one are the same when the condition happens.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    648 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
    574 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X