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

Draw.Region not working ...

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

    Draw.Region not working ...

    for me.

    The code is so simple that I am assuming is missed doing something to get a region to paint between two plot lines as shown in the SS. I put Print statements (not in the code below) to make sure the values are correct, which they are. The indicator does not run in the price panel.

    NT Version is 8.0.14.1 64-bit.

    So, what did I not do correctly?

    Thank you.


    Code:
    protected override void OnBarUpdate()
    {
    	if (CurrentBar < 1)
    	{
    		this.TrendREMA[0]	= 0;
    		this.CycleREMA[0]	= 0;
    		return;
    	}
            if (CurrentBar < 1)
           {
    	    this.TrendREMA[0]	= 0;
    	    this.CycleREMA[0]	= 0;
    	    return;
           }
    	
    	this.TrendREMA[0]	= (trema[0]);
    	this.CycleREMA[0]	= (crema[0]);
    			
    	if( CycleREMA[0] > TrendREMA[0] ) 
    		Draw.Region(this, "CycleAbove", CurrentBar, 0, CycleREMA, TrendREMA,  null, Brushes.LightGreen, 50);	
    			
    	if( CycleREMA[0] < TrendREMA[0] ) 
    		Draw.Region(this, "TrendAbove", CurrentBar, 0, CycleREMA, TrendREMA,  null, Brushes.LightCoral, 50);	
    }
    
    
    
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> TrendREMA
    {
    	get { return Values[0]; }
    }
    
    [Browsable(false)]
    [XmlIgnore]
    public Series<double> CycleREMA
    {
    	get { return Values[1]; }
    }
    Attached Files

    #2
    Hello Cheech,

    Is the only issue that you want your indicator to plot in the price panel?

    In the Indicator parameters set Panel to 'Same as input series', click OK.

    To have the be the default setting, set IsOverlay to true, remove the instance of the script and add a new instance.

    Below is a public link to the help guide on IsOverlay.



    Is the region not appearing in the indicator panel?

    Do you have any errors in the Log tab of the Control Center?

    Is DrawOnPricePanel set to false? (This is true by default)

    Below is a public link to the help guide on DrawOnPricePanel.
    Last edited by NinjaTrader_ChelseaB; 06-10-2018, 09:06 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea

      No, the indicator is not supposed to print in the price panel and the way it is working is fine. The issue is that the DrawRegion between the 2 plots is not working, and no matter how I change things I cannot get it to work.

      Unless told otherwose I can not see anything wrong with the way the Draw.Regions is set up so I am assuming one of the following:

      1. I didn't set some other setting to make it work
      2. I set something to stop it from working
      3. the Draw.Region isn't working as documented.

      Therefore given that I do not want it in the price panel:

      1 "Same as input series" should not be set,
      2. DrawOnPricePanel was unspecified, but I added it and set it to false
      3, isOverlay is set to false, and.
      4. There are no errors in the log

      Let me know if you need any more info.

      Also, I received a note from LIzardIndicators stating that they were having problems with the latest release and recommended backing off to the previous version which I did. No change,

      Regards,

      Frank
      Last edited by Cheech; 06-10-2018, 09:25 PM.

      Comment


        #4
        Hello Frank,

        If you make any changes to the State.SetDefaults, you will need to remove the instance of the script and add a new instance so the defaults can take effect (the defaults are used when adding a new instance).

        May I confirm you removed the script instance and added a new instance?


        I am showing the Draw.Region() method is still working..

        This likely indicates an issue with the script itself.

        Attached is a test script that shows Draw.Region() still works.
        Attached Files
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_ChelseaB View Post
          Hello Frank,

          If you make any changes to the State.SetDefaults, you will need to remove the instance of the script and add a new instance so the defaults can take effect (the defaults are used when adding a new instance).
          .

          Hi Chelsea

          You are correct, I did not add a new instance and once I did the draw regions worked, somewhat.

          Allow me to explain, and given I just started coding for NT8 this may be one of those code breaking things that I don't understand.


          The way it is coded even though the code is entered to plot an alternate color when the Plots cross opposite the color is not changed. I put in Print statements to make sure the comparison test were correct and they are (see attached SS).

          This means that I am not doing something that allows the color to be changed even though the Draw.Region specifies a different color.

          Please advise if this needs to be code differently.

          Thank you

          Code is below:

          Code:
          if( crema[0] > trema[0] )
          			{	
          				Draw.Region(this, "Cycle Above", CurrentBar, 0, crema, trema, null, Brushes.LightGreen, 100);	
          				Print(Time[0].ToString() + "; Cycle above");
          			}
          			
          			else if( crema[0] < trema[0] ) 
          			{
          				Draw.Region(this, "Cycle below", CurrentBar, 0, crema, trema,  null, Brushes.LightCoral, 100);
          				Print(Time[0].ToString() + "; Cycle Below");
          			}
          			else
          				Print(Time[0].ToString() + ";  At Crossing");
          Attached Files

          Comment


            #6
            Hello Cheech,

            Your region is a single drawing object with a single color that spans the entire chart.

            (When re-using a tag name the object is moved / updated instead of a new object being drawn)

            If you want multiple colors, for different bars, then you need multiple drawing objects with different tag names.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_ChelseaB View Post
              Hello Cheech,

              Your region is a single drawing object with a single color that spans the entire chart.

              (When re-using a tag name the object is moved / updated instead of a new object being drawn)

              If you want multiple colors, for different bars, then you need multiple drawing objects with different tag names.
              I do have different tag names

              Draw.Region(this, "Cycle Above", CurrentBar, 0, crema, trema, null, Brushes.LightGreen, 100);

              Draw.Region(this, "Cycle below", CurrentBar, 0, crema, trema, null, Brushes.LightCoral, 100);

              Comment


                #8
                Hello Frank,

                Ah, to correct my statement.. You have two regions that span the entire length of the chart that are on top of each other.
                One is behind the other so only one is visible.
                Are you wanting to hide one behind the other by drawing them both on the same bar range using the same series?


                My meaning was that instead of 1 object that spans the chart, you would have a new separate object for each section you want a different color spanning only that section.
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello Frank,

                  Ah, to correct my statement.. You have two regions that span the entire length of the chart that are on top of each other.
                  One is behind the other so only one is visible.
                  Are you wanting to hide one behind the other by drawing them both on the same bar range using the same series?


                  My meaning was that instead of 1 object that spans the chart, you would have a new separate object for each section you want a different color spanning only that section.
                  Hi Chelsea:

                  I think I am beginning to understand a little more (only a little) about how these regions work. However, I don't think I can correctly express it in technical terms.

                  In English however, when the crema plot line is above the trema plot line I want one color and when the crema plot line is below the trema plot line I want a different color. And I want them to be displayed for the entire chart on a bar by bar basis.

                  Essentially fill the area between the plot lines using 2 different colors based on where the lines are relative to each other and have them visible for the entire chart (with the correct color naturally).

                  I'll leave it to you to translate the English to NS/C# Techna speak.

                  Comment


                    #10
                    Hello Frank,

                    If you want a new color each time the plots cross each other, then increment the tag name of the drawing object when the plots cross each other.

                    Then a new object will be drawn using a new unique tag name each time the cross occurs.

                    The SMARegions indicator does this by setting part of the tag name to CurrentBar any time a breakout occurs.

                    Below is a public link to the SMARegions indicator.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Hi Chelsea:

                      Will check it out, thank you.

                      Comment


                        #12
                        H Chelsea:

                        That worked fine, thanks again.

                        One question, and not to be picky, but is there a way to eliminated the lines in the region that occur between the bars (without using SharpDX that is)? The lines are there in the sample too. I've seen other indicators that do not have them but can't find them at this time. It gives a much better appearance.

                        Thanks,

                        Frank

                        Comment


                          #13
                          Hello Frank,

                          I'm not quite sure what you are referring to.

                          You can disable the vertical grid lines in the chart Properties window if you are referring to these.

                          Or you could draw a small object underneath the region that doesn't have opacity..
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            See attached Chelsea.

                            Not a big deal, just wondering if it could be cleaned up a bit.
                            Attached Files

                            Comment


                              #15
                              Hello Frank,

                              You are probably seeing the vertical grid lines through the opacity of the area.

                              What area opacity have you chosen?
                              Chelsea B.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by arvidvanstaey, Today, 02:19 PM
                              4 responses
                              11 views
                              0 likes
                              Last Post arvidvanstaey  
                              Started by samish18, 04-17-2024, 08:57 AM
                              16 responses
                              61 views
                              0 likes
                              Last Post samish18  
                              Started by jordanq2, Today, 03:10 PM
                              2 responses
                              9 views
                              0 likes
                              Last Post jordanq2  
                              Started by traderqz, Today, 12:06 AM
                              10 responses
                              18 views
                              0 likes
                              Last Post traderqz  
                              Started by algospoke, 04-17-2024, 06:40 PM
                              5 responses
                              48 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X