Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 knighty6508, Today, 01:20 AM
    2 responses
    8 views
    0 likes
    Last Post knighty6508  
    Started by franatas, Today, 01:53 AM
    0 responses
    1 view
    0 likes
    Last Post franatas  
    Started by knighty6508, Today, 01:17 AM
    0 responses
    9 views
    0 likes
    Last Post knighty6508  
    Started by tierraany, Today, 01:06 AM
    0 responses
    4 views
    0 likes
    Last Post tierraany  
    Started by Wilmarobyi, Today, 12:48 AM
    0 responses
    3 views
    0 likes
    Last Post Wilmarobyi  
    Working...
    X