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 color in area between two moving averages?

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

    How to color in area between two moving averages?

    Howdy.

    I am wondering how you would go about filling in an area between two moving averages with an opaque colored plot?

    Also, is there an explanation somewhere how to use that "Plot()" method/function that often resides BELOW the properties section?

    I DO NOT mean the add( new Plot() ) to simply add some plot.

    The function I am speaking of usually starts off this way:
    Code:
    public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)

    #2
    forrestang, overriding the plot method would unfortunately not be really supported by us - for ideas though you can check into the PowerVolume indicator and the CustomPlotSample installed with NT.

    For your area filling question, I would suggest working with DrawRegion() :

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand, I will give this a try!

      Comment


        #4
        Bertrand, I am having a bit of a problem.

        Basically, I have an oscillator, and the oscillator is created with dataSeries containing double values. I simply want to color the area in between the 30 line and the dataSeries making up that oscillator.

        I have tried a variant of all 4 variants on that sample script, and it doesn't seem to work. It compiles, but it doesn't actually produce a shaded area of any type.

        I also tried creating a dataSeries containing the value 30.00 and coloring between my oscillators' dataSeries and the dataSeries containing the value 30.

        Here is a pic of what I am trying to accomplish.
        Attached Files

        Comment


          #5
          Ok, posted this code directly in, and it colored on my chart, but in the price panel. That must have been the problem before.

          How do I tell it to plot in the oscilator panel?

          Comment


            #6
            I think I have it. I will report back!

            Comment


              #7
              Might have another question later, but it seems like the initial problem was needing to add this to initialize:
              Code:
              DrawOnPricePanel 	= false;
              And also removing:
              Code:
              overlay = false;
              I am able to plot on the colors on the indicator panel now.

              Is there a way to be able to customize the plot colors in user input screen using this drawing method?

              Comment


                #8
                forrestang,

                Please see our Tips section on User Definable Color Inputs:



                Even if you're over riding the plot method, this should still work as the the only part you are making public would be the color variable itself.
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  I have another question.

                  Is there a standard practice for plotting a colored ribbon that will stay at the bottom of the price panel based on some conditions for coloring?

                  I am hoping to do this without creating another indicator panel and adding that to the chart.

                  Initially, I was thinking that I would want to find the LOWEST price bar on the chart via MIN() function, and just offsetting that. But I could see how that could get silly looking if someone where to turn off their auto-scale.

                  Is there a function that will allow me to draw something at a fixed location @ all times on the bottom of the price panel? See the picture for an idea of what I am wanting to do.
                  Attached Files

                  Comment


                    #10
                    forrestang,

                    There is not a supported method to draw at a fixed location at all times.

                    Finding the lowest point on the chart would work, but as you mentioned turning off autoscale would change how this behaved.
                    MatthewNinjaTrader Product Management

                    Comment


                      #11
                      I have created a separate indicator, and colored it to look like the price ribbon I wanted to create, only it is sitting in it's own panel. So it's a similar result to what I wanted to do.

                      So now, my chart is basically two indicators. An indicator that plots some things in the Price Panel, and another indicator that plots that ribbon below it.

                      I will have some things plotted in the price panel that are dependent on the calculations in the ribbon. The problem I am having is it seems to be off. By that I mean, I'm telling the price calculation to do something when that ribbon is above a certain level..... and it is not what I expect, as it is doing it when that level is not hit. Like the calculation are evaluating slightly different. They both are accessing the same number of bars as well.

                      Would it be possible to use the add() function in that price indicator, that will automatically add that second panel with the indicator(ribbon) each time the price indicator is loaded, and maybe that will give me some consistent calculations?

                      Does all that make sense?
                      Attached Files

                      Comment


                        #12
                        forrestang, only strategies could Add() indicators for display :



                        I would suggest you remove temporarily all not needed parts and focus on debugging all values in the core calculations to understand why the would return differently for both studies used. Are all parameters of the indicators / methods used 100% the same then, something that one can easily overlook in this aspect...
                        BertrandNinjaTrader Customer Service

                        Comment


                          #13
                          Question on coloring beyond 256 bars

                          Two questions:

                          1) As you can see on this chart, I have some things colored using the DrawRegion() function. Only problem is that you can see when it goes beyond 256 bars, it looses the plot. Not that this is a big deal, is there a way to have the colors remain fixed to the point they are drawn to other than setting the MaximumBarLookBack to greater than 256?

                          2) If the only way is setting the maximum lookback to 'Infinite,' what is the script to add it to the 'Initialize()' section so that it doesn't have to be set in the User Input screen everytime?
                          Attached Files

                          Comment


                            #14
                            You would need to work then with infinite here, please try this in your Initialize() :

                            MaximumBarsLookBack = MaximumBarsLookBack.Infinite;
                            BertrandNinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by helpwanted, Today, 03:06 AM
                            1 response
                            11 views
                            0 likes
                            Last Post sarafuenonly123  
                            Started by Brevo, Today, 01:45 AM
                            0 responses
                            9 views
                            0 likes
                            Last Post Brevo
                            by Brevo
                             
                            Started by aussugardefender, Today, 01:07 AM
                            0 responses
                            5 views
                            0 likes
                            Last Post aussugardefender  
                            Started by pvincent, 06-23-2022, 12:53 PM
                            14 responses
                            242 views
                            0 likes
                            Last Post Nyman
                            by Nyman
                             
                            Started by TraderG23, 12-08-2023, 07:56 AM
                            9 responses
                            387 views
                            1 like
                            Last Post Gavini
                            by Gavini
                             
                            Working...
                            X