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

Change single bar color

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

    Change single bar color

    Hi,

    I'm trying to make an indicator to change the color of a single bar when I get a long/short signal. Anyone know how I can go about doing that?

    This is how it currently looks like:

    if (long signal)
    {
    BarColor = Color.Gold;
    }


    else if (short signal)
    {
    BarColor = Color.Silver;
    }

    My programming knowledge is very limited (to a few hours from How to's on youtube).

    - Stoop

    #2
    Stoop,

    This looks ok here, i.e. it appears it would work.

    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Hi,
      Thanks for your reply, I figured out what was wrong. I had an indicator using ATR(20) and realised it wouldn't show anything because I was missing:
      if (CurrentBar < 21)
      return;

      Anyways, I have another question I was hoping you could help me with. I have tried searching around for it but can't seem to find an answer. When I run my indicator it doesn't use the latest bar, even though it's closed. Or rather, it doesn't draw my indicator all the way to the latest bar. I tried looking at the standard DonchianChannel Indicator but the same thing happens to that one as well.
      The only option I have found is to use Displacement = 1, but that doesn't really help.

      Do you have an idea on how I can fix that?

      Comment


        #4
        Stoop,

        Unfortunately I would need to see more code here. Could you post the problem section of your code?
        Adam P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by Stoop View Post
          Hi,
          Thanks for your reply, I figured out what was wrong. I had an indicator using ATR(20) and realised it wouldn't show anything because I was missing:
          if (CurrentBar < 21)
          return;

          Anyways, I have another question I was hoping you could help me with. I have tried searching around for it but can't seem to find an answer. When I run my indicator it doesn't use the latest bar, even though it's closed. Or rather, it doesn't draw my indicator all the way to the latest bar. I tried looking at the standard DonchianChannel Indicator but the same thing happens to that one as well.
          The only option I have found is to use Displacement = 1, but that doesn't really help.

          Do you have an idea on how I can fix that?
          If you want an indicator to plot on the current bar as it is developing, you have to set CalculateOnBarClose to "false".

          Comment


            #6
            It was just the CalculateOnBarClose that had to be set to false. I guess I just didn't think about that because I thought the bars were done developing.

            Thanks a lot to the both of you!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rocketman7, Today, 02:12 AM
            5 responses
            23 views
            0 likes
            Last Post rocketman7  
            Started by trilliantrader, 04-18-2024, 08:16 AM
            7 responses
            28 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by samish18, 04-17-2024, 08:57 AM
            17 responses
            66 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by briansaul, Today, 05:31 AM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by PaulMohn, Today, 03:49 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Working...
            X