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 set a bar color intra-day

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

    How to set a bar color intra-day

    Hi,

    Can anyone tell me how to change the color of the current and subsequent bars midstream via Ninja Script. What I'm trying to do is write something that would allow the price bars to change shade or color as it passes a particular time of the day. So if the price bars are originally green during regular market hours their color would change to another designated color once time has reached, let say, 4:15PM. Then the bars would change back to their original colors when it becomes 9:30AM, to show regular and non-regular market hours.

    I've been fooling around writing some indicators in ninja script but can't figure out how to do this.

    Regards,
    Johnny

    #2
    Hello Spartacus,

    Thank you for your post.

    You can filter for time conditions. The reference samples below is used to limit trading during certain hours, but you might be able to modify the concepts to paint a bar at certain hours:


    You change BarColor using the barcolor property:



    You can add a check to only run on real-time data. Add this in the OnBarUpdate() section:
    Code:
     
    if (Historical)
       return;
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan

      Hi Ryan,

      Thank you and it worked.

      I assumed that working for bar type would also work for candle. Please see attached and can you comment on how to get it to work for candle as well as bar types. The stems seem uncolored. I mean that's good enough, but to distinquish between up & down candles, and the stems, do you have further suggestions? thanks!

      Regards,
      Spartacus
      Attached Files

      Comment


        #4
        Hi Jonny,

        Which version of NinjaTrader are you using? There's a change to the BarColor property in version 7.

        Taken from:
        Contains critical information including but not limited to migration, installation, connections and changes.


        BarColor no longer colors the entire bar. It will color the bar body only. To color the bar outline please use CandleOutlineColor.


        If you want Up/Down Colors you would have to add two extra conditions to evaluate and then paint the bars different colors. Something like:
        Code:
         
         
        if (Close[0] > Open[0] && yourTimeFilter)
             setYourUpColorHere;
         
        if (Close[0] <= Open[0] && yourTimeFilter)
             setYourDownColorHere;
        You might also consider changing the BackColor instead of the BarColor.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Hi Ryan,

          Thanks for the information, very helpful. I am using NT7b9.

          In the NT7 documentation I didn't come across anything like the member variable CandleOutlineColor that you pointed out in in the previous message, would you know what sources I can look at to find out such information?

          I would like to make all the components (UP bar, DOWN bar, candle OUTLINE, "TO TIME", "FROM TIME) parameter driven. I have a good idea how to do it for integers (time components) when making the time parameters configurable, but for colors I simply don't know how to offset into the "plot" object to access the color so that I can store it into a local variable. Do I use the Ninja script wizard to plot the color? If so how would I reference that color from within the onBarUpdate method?

          Your suggestion about changing the background color instead sounds just as good, however I'd like to get used to manipulating price bars as well.

          Ryan, Thanks for your assistance.
          Last edited by Spartacus; 02-16-2010, 08:07 PM.

          Comment


            #6
            Hi Spartacus,

            Thanks for your comments. Below are a couple more links that should help.

            NinjaTrader 7 Code Breaking Changes.

            Creating User Definable Color Inputs.
            Ryan M.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Kaledus, Today, 01:29 PM
            0 responses
            3 views
            0 likes
            Last Post Kaledus
            by Kaledus
             
            Started by PaulMohn, Today, 12:36 PM
            1 response
            16 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by yertle, Yesterday, 08:38 AM
            8 responses
            36 views
            0 likes
            Last Post ryjoga
            by ryjoga
             
            Started by rdtdale, Today, 01:02 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Started by alifarahani, Today, 09:40 AM
            3 responses
            18 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X