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 algospoke, Yesterday, 06:40 PM
            2 responses
            23 views
            0 likes
            Last Post algospoke  
            Started by ghoul, Today, 06:02 PM
            3 responses
            14 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by jeronymite, 04-12-2024, 04:26 PM
            3 responses
            45 views
            0 likes
            Last Post jeronymite  
            Started by Barry Milan, Yesterday, 10:35 PM
            7 responses
            21 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by AttiM, 02-14-2024, 05:20 PM
            10 responses
            181 views
            0 likes
            Last Post jeronymite  
            Working...
            X