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 cmoran13, 04-16-2026, 01:02 PM
          0 responses
          42 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          25 views
          0 likes
          Last Post PaulMohn  
          Started by CarlTrading, 03-31-2026, 09:41 PM
          1 response
          162 views
          1 like
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 04-01-2026, 02:41 AM
          0 responses
          98 views
          1 like
          Last Post CarlTrading  
          Started by CaptainJack, 03-31-2026, 11:44 PM
          0 responses
          157 views
          2 likes
          Last Post CaptainJack  
          Working...
          X