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 SalmaTrader, 07-07-2026, 10:26 PM
        0 responses
        35 views
        0 likes
        Last Post SalmaTrader  
        Started by CarlTrading, 07-05-2026, 01:16 PM
        0 responses
        20 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 06-17-2026, 10:32 AM
        0 responses
        12 views
        0 likes
        Last Post CaptainJack  
        Started by kinfxhk, 06-17-2026, 04:15 AM
        0 responses
        18 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Started by kinfxhk, 06-17-2026, 04:06 AM
        0 responses
        20 views
        0 likes
        Last Post kinfxhk
        by kinfxhk
         
        Working...
        X