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

DrawRegion question

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

    DrawRegion question

    Is there a reason DrawRegion does not work in a panel other than panel 1 or am I doing something wrong?
    eDanny
    NinjaTrader Ecosystem Vendor - Integrity Traders

    #2
    It should work in any panel. Please use DrawOnPricePanel = false.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Man I totally overlooked that because I was thinking Overlay = false did that. Thanks for the reminder.
      eDanny
      NinjaTrader Ecosystem Vendor - Integrity Traders

      Comment


        #4
        Originally posted by eDanny View Post
        Man I totally overlooked that because I was thinking Overlay = false did that. Thanks for the reminder.
        I went through the exact same thing. Glad I found this post.

        Quick question:

        Do you have a code snippet for shading the areas that are not in your trading session. I want to see the part I am trading in white, and the non-tradeable hours in gray or whatever.

        I am sure someone has done this, and I was hoping someone could save me the pain!

        Example:
        normal between 9:30am and 4pm
        gray outside of those frames.

        My guess is I need to get the bar for the time, etc. and drop those in the DrawRegion, etc., but being it's my first time attempting this, I see pain ahead for a mere mortal attempting to program said.

        Anyone?


        Thanks,

        Comment


          #5
          You would just make yourself a time filter and use BackColor.

          Code:
          if (ToTime(Time[0]) > _____ && ToTime(Time[0]) < ________)
               BackColor = Color.Gray;
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Oh! I'm a new man and should get more life out of my eyes.

            Thanks Josh, worked fine.

            Spoke too soon :-(

            I need the inverse. I would like the trading hours normal (from to) and the area outside that range to be grayed.

            I tried to inverse what you gave me, but it is giving nothing. My guess is that it is happening sequentially and i can't go backwards.

            Do I need to use the GetBars in my case with DrawRegion?

            UPDATE:

            my first guess is to set default background to the color I want, and then use your snippet to set the trading hours to normal??

            Thanks,
            Last edited by r2kTrader; 06-09-2009, 02:25 PM.

            Comment


              #7
              How about if you just set your chart background color to the gray in chart properties and in the code set the BackColor = Color.White?

              Edit: Oops too slow, I see you have figured it out.
              eDanny
              NinjaTrader Ecosystem Vendor - Integrity Traders

              Comment


                #8
                MultiTimeFrame - Strange Coloring

                It might be a good idea to put this snippet under your primary test code:

                if (BarsInProgress() == 0)
                BackColor = Color.Gray;
                if (ToTime(Time[0]) > 80000 && ToTime(Time[0]) < 160000)
                BackColor = Color.White;

                I was getting strange color placement and was about to post a question. But then I realized it might have to do with the fact that I had this at the top of my OnBarUpdate() and not in my bip test. I threw it under than and I am right as rain.

                I hope this helps someone.

                Thanks!

                PS, eDanny, pick up the pace bud! The reply from you was well over 30 seconds! lol, thanks for pitching in so promptly.

                Comment


                  #9
                  Just wanted to update this thread for anyone who might want to know how to do the same thing.

                  I changed my code so that my grayed out area would be through all the panels and not just the chart. Helps me line up the indicators with the session I am watching.

                  If in a multi-instrument/time strategy, make sure you put this under bars in progress that tests for 0, or primary or your charts will be whacked out color wise.

                  Instead of using "white" I went with empty, felt "cleaner".

                  Also, I tried to put the default color under Initialize() but it broke the whole strategy. So if you want your shade to go through the chart and the panels below, then use what I have below.

                  Hope this helps someone.


                  // Set default background for the chart to gray.
                  BackColorAll = Color.LightGray;
                  if (ToTime(Time[0]) > 80000 && ToTime(Time[0]) < 160000)
                  BackColorAll = Color.Empty;

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by timmbbo, Today, 08:59 AM
                  1 response
                  2 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by KennyK, 05-29-2017, 02:02 AM
                  2 responses
                  1,280 views
                  0 likes
                  Last Post marcus2300  
                  Started by fernandobr, Today, 09:11 AM
                  0 responses
                  2 views
                  0 likes
                  Last Post fernandobr  
                  Started by itrader46, Today, 09:04 AM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by bmartz, 03-12-2024, 06:12 AM
                  5 responses
                  33 views
                  0 likes
                  Last Post NinjaTrader_Zachary  
                  Working...
                  X