Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi-colored background colors?

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

    Multi-colored background colors?

    Hi Ninjas everywhere

    I really doubt if this is possible but here goes:

    Is there any conceivable way of coding such that, for example, on an ES chart, the background color between, say, the 1938 and 1940 levels is green; background color between the 1940 and 1942 levels is blue, etc., etc.

    Thanks in advance for any advice about this - but I'm not hopeful!

    #2
    Hello,

    Thank you for the question.

    While there is not really a documented way of doing this you could certainly do this.

    What you would be facing would be using the Plot override rather than using the built in coloring methods.

    The plot override takes advantage of Graphics C# and there are some methods in NinjaTrader which can help you translate the bars number to an X position on the screen and the same with price to a Y position.

    We have a few examples on this, one is the CustomPlotSample indicator.

    You will find in these examples the "Miscellaneous" section which contains
    Code:
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
    { }
    This is the plot Override which gives you access to Graphics which is what is used to draw the graphics, then you have the bounds which relates to NinjaTraders screen bounds.

    Another example would be the Pivots indicator, this draws the lines for the pivots indicator.

    After all of this you can use the following two methods to get your screen position based on NinjaTrader data

    Code:
    int lastX = ChartControl.GetXByBarIdx(BarsArray[0], insertBarNumberHere);
    float yOpen = ChartControl.GetYByValue(this, open[0]);
    Finally you can use drawing like the following to achieve a region

    Code:
     graphics.FillRectangle(new SolidBrush(Color.Green), lastX, yHigh, insertWidthHere, insertHeightHere);
    Finally there are some other helpful methods as the bar index can get confusing while using this method, rather than running the calculation through your entire dataseries you can choose to only paint the viewable area or the amount of bars on screen.

    For that you can get the bar index of the left most bar on the screen currently by using:
    Code:
    ChartControl.FirstBarPainted
    and the last most bar by using:
    Code:
    ChartControl.LastBarPainted;
    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thanks very much, Jesse, for going into so much detail.

      Not only is this possible but there's more than one approach.

      This needs careful study and experimentation.

      If I have any further questions, I'll be back here with them.

      Much obliged.

      Comment


        #4
        Originally posted by arbuthnot View Post
        Thanks very much, Jesse, for going into so much detail.

        Not only is this possible but there's more than one approach.

        This needs careful study and experimentation.

        If I have any further questions, I'll be back here with them.

        Much obliged.
        Check out the colorzone indicator in the file sharing section.

        I was able to modify it to suit my needs nicely.
        Attached Files

        Comment


          #5
          Originally posted by sledge View Post
          Check out the colorzone indicator in the file sharing section.

          I was able to modify it to suit my needs nicely.
          Much obliged as always, Sledge.

          Would you believe it? I'd already downloaded this yonks ago and had no idea it could be of use.

          The coding is going to prove really helpful.

          Many thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by hazylizard, Today, 08:38 AM
          2 responses
          8 views
          0 likes
          Last Post hazylizard  
          Started by geddyisodin, Today, 05:20 AM
          2 responses
          17 views
          0 likes
          Last Post geddyisodin  
          Started by Max238, Today, 01:28 AM
          5 responses
          47 views
          0 likes
          Last Post Max238
          by Max238
           
          Started by giulyko00, Yesterday, 12:03 PM
          3 responses
          13 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by habeebft, Today, 07:27 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_ChristopherS  
          Working...
          X