Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Above or below Plot

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

    Above or below Plot

    Above or below Plot

    Hello everyone, I have a code

    Values[0][0] = SomePrice;

    if (Close[0] < Values[0][0])
    {
    BarBrushes[0] = Color1;
    }

    This code color all bars when the line crosses.

    How do I make only one bar color that crosses the line?

    #2
    Hello memonolog,

    Thanks for your post.

    In order to only color the bar on the cross, you will have to change the condition to evaluate. Currently, your condition would remain true as long as the close price is less than the plot.

    There are a couple of ways to determine a cross:

    Use the CrossAbove, CrossBlow methods: https://ninjatrader.com/support/help...crossabove.htm https://ninjatrader.com/support/help...crossbelow.htm

    or Change your condition to test if the previous bar was above (or below) the plot (which is what the crossAbove and crossbelow methods actually do):

    if (Close[0] < Values[0][0] && Close[1] > Values[0][1]) // crossbelow
    {
    BarsBrush = Color1;
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    63 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    90 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    47 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    105 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    63 views
    0 likes
    Last Post PaulMohn  
    Working...
    X