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 inside Plot value

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

    DrawRegion inside Plot value

    Hello:

    I'm writing one custom indicator with one line crossing 0 lines.

    I want to fill between line and 0 value. Green color if upper to 0 and Red color on down to 0.

    If i use only one color to fill, the fill it's ok and fine, the line 0 crossing it's just of one pixel.

    But, if i use two colors, it's allways outsiding the plot value, because it's filling only from/to the middle of current bar and not full of current bar.

    In the first attached file, you can view black crossing it's ok, but in the first circle the red fill it's not fullfilled in the right, and the second fill it's the same in the right and outside in the left.

    The code is:
    Code:
    DrawRegion("Coloured "+CurrentBar,0,1, PlotMainDown, 0,ColorDown, ColorDown, 10);
    In the second attached file, i tryed to change fill barsAgo from 0 to -1 and the fill always outside in the right:
    Code:
    DrawRegion("Coloured "+CurrentBar,-1,1, PlotMainDown, 0,ColorDown, ColorDown, 10);
    I cant put '-0.5,0.5' of course..

    ¿Any idea?

    Thank you in advance
    Attached Files

    #2
    Hello jatubio,

    Thank you for your post.

    You might get a cleaner implentation if you use multi-colored plots instead of draw regions. Using this approach you can set the plot style to "bar".

    This tutorial discusses how to do this as well as this reference sample.

    Basically you will have two plots with min and max values with colors assigned to each.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you for your response RyanM.

      But, if i use bars, the fill it's corned and not soft or rounded..

      Code:
      			if(value>0)
      				PlotColors[0][0]=ColorUp;
      			else
      				PlotColors[0][0]=ColorDown;
      Attached Files

      Comment


        #4
        jatubio, likely because of the way you're values are calculated, have tried the smaller width setting for the the histogram / bar style? Would you mind posting a picture with calculated values just set to a basic linestyle so we can can gauge what you're dealing with here?

        Thanks
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Bretrand, thank you for your interest

          Here is three images, one for bars with width=5 , one for bars with width=1 and one for line with width=1

          In the line image, the orange it's zero line. It's curious how it's drawing the colors here.
          Attached Files

          Comment


            #6
            Hello Jatubio,

            DrawRegion() will be tied to bar objects (minimum is one bar) and this is why you're seeing the colors overlap during a cross over.

            You would need to override the Plot method to change this behavior. Unfortunately this technique is beyond the level of support we offer.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              jatubio, it appears that if the value for the current bar is above zero, then the line is colored from the previous point to that point and vice versa for the red being below zero. Did you look at the samples provided by RyanM? From what I can tell, it is very close to what you're trying to do (which may actually be impossible).
              Attached Files
              AustinNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_RyanM View Post
                Hello Jatubio,

                DrawRegion() will be tied to bar objects (minimum is one bar) and this is why you're seeing the colors overlap during a cross over.

                You would need to override the Plot method to change this behavior. Unfortunately this technique is beyond the level of support we offer.
                RyanM, Thank you very much for the help.

                This functionality is present in most graphics programs would be a good idea bag and include it by default in Ninja Trader.

                Add something like a new kind of plot that is FilledLine or something and that they even have two different colors at the junction with a specific value. And then the user can change any indicator plot to 'FilledLine' from Indicator Properties Popup.

                Best Regards

                Originally posted by NinjaTrader_Austin View Post
                jatubio, it appears that if the value for the current bar is above zero, then the line is colored from the previous point to that point and vice versa for the red being below zero. Did you look at the samples provided by RyanM? From what I can tell, it is very close to what you're trying to do (which may actually be impossible).
                Austin, this is my code, based on samples of Multicolored indicators:

                if(value>0)
                PlotColors[0][0]=ColorUp;
                else
                PlotColors[0][0]=ColorDown;

                And the code based con Custom ROC is:

                PlotMainAbove.Set(value);
                PlotMainBelow.Set(value);

                I have attached two images, the first, MultiColor approach, the second, Two Plots approach.

                As you can see, the drawing in the MultiColor approach is different at the Two Plots approach.

                ¿It's possible to get the Two Plots drawing approach in one filled region?

                Thank you in advance
                Attached Files

                Comment


                  #9
                  Thanks for the detailed reply jatubio, this is unfortunately not possible with the supported methods, you could override the Plot() method and custom code this using C# techniques on your own, see for example the CustomPlotSample we provide per default.

                  Another way to get closer would be using a second identical plot, but setting this to bars / histogram style then, as could be seen in many shared indicators around here.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Thank you Bertrand.

                    I continue to try, if i get working, i share here.

                    Best regards

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by ursavent, Today, 12:54 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post ursavent  
                    Started by Mizzouman1, Today, 07:35 AM
                    3 responses
                    17 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Started by RubenCazorla, Today, 09:07 AM
                    2 responses
                    13 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by i019945nj, 12-14-2023, 06:41 AM
                    7 responses
                    82 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by timmbbo, 07-05-2023, 10:21 PM
                    4 responses
                    158 views
                    0 likes
                    Last Post NinjaTrader_Gaby  
                    Working...
                    X