Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 colorbar

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

    NT8 colorbar

    Hi,

    I need following colorbars indicator for NT8

    if close > ema 8 and ema21 Bar color = Green

    if close < ema 8 and ema21 Bar color = Red
    if the above two condotions are not met Bar color = blue

    #2
    Hello vinay,

    Thank you for writing in.

    Please note that while we do not provide programming services, this is a relatively simple indicator to program.

    Please take a look at the following code below:
    Code:
    protected override void OnBarUpdate()
    {
    	if (Close[0] > EMA(8)[0] && Close[0] > EMA(21)[0])
    		BarBrush = Brushes.Green;
    	else if (Close[0] < EMA(8)[0] && Close[0] < EMA(21)[0])
    		BarBrush = Brushes.Red;
    	else
    		BarBrush = Brushes.Blue;
    }
    For more information about BarBrush, please take a look at this help guide link: https://ninjatrader.com/support/help.../?barbrush.htm

    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks for this. Really appreciate this.

      vinay

      Comment


        #4
        BarBrush

        I am trying to reference a 5 minute bar's close to the previous bar's close in addition to comparing highs and lows. Below is what I have but it doesn't color any bars. Am I not referencing each bar's close, high and low correctly?

        protected override void OnBarUpdate()
        {
        if (Close[0] > Close[1] && Low[0] < Low[1])
        BarBrush = Brushes.Green;
        else if (Close[0] < Close[1] && High[0] > High[1])
        BarBrush = Brushes.Red;
        else
        BarBrush = Brushes.Black;
        }

        Comment


          #5
          Hello josef,

          Thanks for your post.

          When you run your script, do you see any error messages listed in the "Log" tab of the NinjaTrader control center?

          Based on what you are showing you may have an indexing error on the first bar loaded which you can prevent by placing this line ahead of your code in OnBarUpdate(): if (Currentbar < 1) return;
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            When I compile it I don't see any errors. Also, I can't find a "Log" tab. I'm using NT8. When I added your recommended code I do get the following error code: CS0103

            Did I put it in the correct spot?

            protected override void OnBarUpdate()
            {
            if (Currentbar < 1) return;
            if (Close[0] > Close[1] && Low[0] < Low[1])
            BarBrush = Brushes.Green;
            else if (Close[0] < Close[1] && High[0] > High[1])
            BarBrush = Brushes.Red;
            else
            BarBrush = Brushes.Black;
            }

            Comment


              #7
              Hello josef,

              Thanks for your reply.

              In the NinjaTrader8 control center, the tabs are located at the bottom of the control center. Typically you will have "Orders", "Executions", "Strategies", "Positions", "Accounts", "Log" and "+". If you do not see "Log" then click the "+ " and select Log.


              In the code I provided there was a typo, here is the correctly capitalized version:

              if (CurrentBar < 1) return;
              Paul H.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Jon17, Today, 04:33 PM
              0 responses
              1 view
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              4 views
              0 likes
              Last Post Javierw.ok  
              Started by timmbbo, Today, 08:59 AM
              2 responses
              10 views
              0 likes
              Last Post bltdavid  
              Started by alifarahani, Today, 09:40 AM
              6 responses
              40 views
              0 likes
              Last Post alifarahani  
              Started by Waxavi, Today, 02:10 AM
              1 response
              19 views
              0 likes
              Last Post NinjaTrader_LuisH  
              Working...
              X