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

Slight Error in Condtional Statement Indicator, need help, Ninja trader 7

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

    Slight Error in Condtional Statement Indicator, need help, Ninja trader 7

    I have a slight error in my conditional statement indicator that I am inputting. The goal is to plot a Black Diamond above the price bars where all of the conditions are true, and have the diamonnd flash on and off of the screen as the conditions are being met on a tick by tick basis.

    So far I have a black diamond appearing over every single price bar....my basic conditions are these: High of current bar >= High of 3 bars ago and Close of current bar < Close of 3 bars ago.

    Here is the ninja script I am using:

    if(CurrentBar<2)return;if((High[0]>=High[-3])&&(Close[0]<Close[-3])); DrawDiamond("tag1" + CurrentBar,true,0,High[0]+(TickSize+.10),Color.Black);
    }

    Any help is much appreciated...for some reason the diamond is being plotted on every bar, so I guess my conditional statements are not being recognized.

    #2
    Originally posted by vern13 View Post
    I have a slight error in my conditional statement indicator that I am inputting. The goal is to plot a Black Diamond above the price bars where all of the conditions are true, and have the diamonnd flash on and off of the screen as the conditions are being met on a tick by tick basis.

    So far I have a black diamond appearing over every single price bar....my basic conditions are these: High of current bar >= High of 3 bars ago and Close of current bar < Close of 3 bars ago.

    Here is the ninja script I am using:

    if(CurrentBar<2)return;if((High[0]>=High[-3])&&(Close[0]<Close[-3])); DrawDiamond("tag1" + CurrentBar,true,0,High[0]+(TickSize+.10),Color.Black);
    }

    Any help is much appreciated...for some reason the diamond is being plotted on every bar, so I guess my conditional statements are not being recognized.
    Correct is:

    Code:
    if(CurrentBar<3) return;
    if((High[0]>=High[3])&&(Close[0]<Close[3])) DrawDiamond("tag1" + CurrentBar.ToString(),true,0,High[0]+(TickSize+.10),Color.Black);
    Your code has a semi-colon terminating the second if statement, turning it into a null statement, so your drawing code would be called on every bar.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    149 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Started by GussJ, 03-04-2020, 03:11 PM
    16 responses
    3,283 views
    0 likes
    Last Post Leafcutter  
    Working...
    X