Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Region drawing on Price Panel not Indicator

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

    Draw.Region drawing on Price Panel not Indicator

    I am attempting to use Draw.Region to fill between two series on an indicator panel. Draw.Region() is drawing on the Price panel.

    I have set
    DrawOnPricePanel = false;


    I would expect that the "this" pointer passed to Draw.Region would implicitly reference the indicator panel and not the price panel.

    I must be doing something dumb... Lots of coding in NT6/7 but I'm new to NT8.

    Code:
        public class MyStochRSI : Indicator
        {
            private    Series<double>        HighLine;
            private    Series<double>        LowLine;
            
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                         = @"StochRSI with StockCharts.com-style coloring";
                    Name                                 = "MyStochRSI";
                    Calculate                            = Calculate.OnEachTick;
                    IsOverlay                            = false;
                    DisplayInDataBox                = true;
                    DrawOnPricePanel              = false;
                    DrawHorizontalGridLines      = true;
                    DrawVerticalGridLines          = true;
                    PaintPriceMarkers               = false;
                    ScaleJustification                = Gui.Chart.ScaleJustification.Right;
                    //Disable this property if your indicator requires custom values that cumulate with each new market data event. 
                    //See Help Guide for additional information.
                    IsSuspendedWhileInactive    = true;
                    Period                                 = 9;
                    AddPlot(Brushes.Green, "RSILine");
                }
                else if (State == State.Configure)
                {
                    HighLine    = new Series<double>(this);
                    LowLine     = new Series<double>(this);                
                }
            }
    
            /// <summary>
            /// Called on each bar update event (incoming tick)
            /// </summary>
            protected override void OnBarUpdate()
            {        
                HighLine[0] = 80.0;
                LowLine[0] = 20.0;
                RSILine[0] = 100.0 * StochRSI(Period)[0];
                
                if (RSILine[0] >= HighLine[0])
                {
                    Draw.Region(this, "StochRSI_High"+CurrentBar, 1, 0, RSILine, HighLine, Brushes.Black, Brushes.Green, 50);
                                  
                }
    
                else if (RSILine[0] <= LowLine[0])
                {
                    Draw.Region(this, "StochRSI_Low"+CurrentBar, 1, 0, LowLine, RSILine, Brushes.Black, Brushes.Green, 50);
                    
                }
                
    
            }
            #region Properties
            [Range(1, int.MaxValue)]
            [NinjaScriptProperty]
            [Display(Name="Period", Order=1, GroupName="Parameters")]
            public int Period
            { get; set; }
    
            [Browsable(false)]
            [XmlIgnore]
            public Series<double> RSILine
            {
                get { return Values[0]; }
            }
            #endregion
    
        }
    }
    I have attached my project.
    Attached Files
    Last edited by scenewright; 11-02-2015, 02:29 PM.

    #2
    Hello,

    I'm not seeing the same thing running your indicator on my end (see image attached), but perhaps I'm misunderstanding the scenario. Have you placed the indicator in the same panel as the bars series, and wish to draw in a new panel?
    Attached Files
    Dave I.NinjaTrader Product Management

    Comment


      #3
      Wow, You are getting what I wanted. But I'm not. I could make changes to the script, compile, and reload in my chart and see differences, but it would not draw the fill regions.

      I deleted the indicator completely from the chart and re-added it and now I see them like you do.
      I imagine that's probably not a repeatable problem, but it might be worth thinking about how that might happen.

      Thanks for the help and verification.

      As a side note, I was hoping that maybe NT8 would provide a "fix" for my problem (which you can see in your screenshot) where I really want to only color the area above or below the line, but just as in NT 6 and 7, the Draw.Region colors on both sides of the line when the crossing happens within a single candle-width.

      -Jim

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by geotrades1, Today, 10:02 AM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by ender_wiggum, Today, 09:50 AM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by rajendrasubedi2023, Today, 09:50 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by bmartz, Today, 09:30 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Erick  
      Started by geddyisodin, Today, 05:20 AM
      3 responses
      26 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X