• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 faisamtrader, Today, 10:31 AM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Tyler  
              Started by ChazJ, Today, 09:48 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by maxie, Today, 10:01 AM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Melissa  
              Started by Bionian, Today, 09:36 AM
              1 response
              4 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Started by tomd, Today, 09:48 AM
              1 response
              12 views
              0 likes
              Last Post NinjaTrader_Ariana  
              Working...
              X