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 Hwop38, 05-04-2026, 07:02 PM
    0 responses
    161 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    311 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    245 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    350 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    179 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X