Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

doing nothing

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

    doing nothing

    Hello-
    I have a condition:
    if (myvar >= 1.00)
    { print dot}
    else {do nothing}

    I get the unassigned variable error if I leave the else out. So I have to assign myvar to something, so I chose 0. But now I get a dot at every bar on the zero line.
    I only want a dot when (myvar >= 1.00) and nothing if it's < 1.00. How is this done?
    Thank you.

    #2
    Hello imalil, thanks for your post.

    You can add a ';' within your ELSE block and that would be an empty NOOP statement. You can also just remove the entire ELSE block to do nothing if the above condition is false.

    Kind regards.

    Comment


      #3
      Thanks for the answer, I'll try the ;. I have to ask because I'm trying to learn: when I remove the else block with my variable assigned, myvar = 0;, it compiles but I get a dot on the zero line at every bar, which I don't want. When I remove the else statement and not assign myvar, I get an unassigned variable error. So in my situation removing the else block doesn't work, unless I'm missing something, which is highly possible and why I'm asking.
      Thanks.

      Comment


        #4
        Hi imalil, thanks for your reply.

        I can't tell why you are getting that unassigned value error from the snippet you posted. If you could post your script here I can take a look. See here for instructions on exporting.

        I look forward to hearing from you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        156 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        90 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        140 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        130 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        107 views
        0 likes
        Last Post CarlTrading  
        Working...
        X