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

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 DJ888, Today, 10:57 PM
          0 responses
          2 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          158 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Today, 09:29 PM
          0 responses
          7 views
          0 likes
          Last Post Belfortbucks  
          Started by zstheorist, Today, 07:52 PM
          0 responses
          7 views
          0 likes
          Last Post zstheorist  
          Started by pmachiraju, 11-01-2023, 04:46 AM
          8 responses
          151 views
          0 likes
          Last Post rehmans
          by rehmans
           
          Working...
          X