Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to paint only first bar that meets condition?

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

    How to paint only first bar that meets condition?

    How can I paint only the FIRST bar that meets this specific (rising/falling) condition and not every bar meeting this condition?
    if(Rising(MACD(12, 26, 9).Avg))

    BarColor = Color.Green;

    else

    BarColor = Color.Red;
    I'm stumped and cannot seem to locate any help in the forums.

    #2
    Not sure if this will help....but if you are comparing one line to another....you can try CrossAbove & CrossBelow commands.

    if (CrossAbove (FastLine, SlowLine, 1))

    (the syntax is in the NinjaHelp files.

    Comment


      #3
      Yes, the CrossAbove/Below conditions will work for those conditions, but I am specifically trying to paint the bar when using the Rising/Falling condition. Unfortunately, there is only one reference (the MACD average) in the statement and it does not cross above or below any other line. I just need a marker when the MACD average changes direction.

      Comment


        #4
        Hello,

        Use a bool flag something like this:

        if(...your conditions here... && bIsTime)
        {
        //do something
        bIsTime = false;
        }

        Note you will have to reset bIsTime to true in your other condition or somewhere else.
        DenNinjaTrader Customer Service

        Comment


          #5
          Thanks, Ben.

          I'll give that a try.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          31 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          21 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          184 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Started by CaptainJack, 04-24-2026, 11:07 PM
          0 responses
          341 views
          0 likes
          Last Post CaptainJack  
          Started by Mindset, 04-21-2026, 06:46 AM
          0 responses
          264 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X