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 with RegressionChannel

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

    DrawRegion with RegressionChannel

    Hello,

    I'm attempting to fill in the areas between the middle and lower regression channel lines using DrawRegion() but seem to be coloring between the actual linear regression line and its deviation. I have the following at the bottom of protected override void OnBarUpdate():

    Code:
    Middle.Set(middle);
    Upper.Set(middle + stdDeviation * Width);
    Lower.Set(middle - stdDeviation * Width);
    
    DrawRegion("tag1", CurrentBar, 0, RegressionChannelRegion(period, 4).Lower, RegressionChannelRegion(period, 4).Middle, Color.Empty, Color.Lime, 2);
    Should this go elsewhere or call another dataseries?

    Thanks for any help anyone can provide.
    Last edited by WhoDat; 04-16-2017, 09:10 AM.

    #2
    Apologies - this belongs under NinjaTrader 7 but I'm not sure how to delete or move it.

    Comment


      #3
      Hello WhoDat,

      You have not included enough information for me to test.

      Is RegressionChannelRegion an indicator you have created yourself?

      Instead I've called the original RegressionChannel indicator and I was able to reproduce the behavior.

      The region appears to be twice the distance it should be.

      I'm asking our development about this.


      To export a NinjaTrader 7 NinjaScript do the following:
      1. Click File -> Utilities -> Export NinjaScript
      2. Enter a unique name for the file in the value for 'File name:'
      3. Select the strategy from the objects list on the left -> click the right facing arrow ">" to add the strategy to the export
      4. Click the 'Export' button -> click 'yes' to add any referenced indicators to the export -> click OK to clear the export location message


      By default your exported file will be in the following location:
      • (My) Documents\NinjaTrader 7\bin\Custom\ExportNinjaScript\<export_file_name.z ip>


      Below is a link to the help guide on Exporting NinjaScripts.
      http://www.ninjatrader.com/support/h...nt7/export.htm
      Attached Files
      Chelsea B.NinjaTrader Customer Service

      Comment


        #4
        Hi Chelsea,

        It's actually NT's pre-installed indicator. All I did was add the DrawRegion() line.

        Thanks for taking a look. We seem to be using very different numbers for period and width, which could explain your results. I'm just confused as to why it doesn't line up with the plotted lines.

        I can still upload the full script if you need.

        Thanks.

        Comment


          #5
          Hello WhoDat,

          NinjaTrader does not have an indicator called RegressionChannelRegion.

          My guess is that you have made a copy of RegressionChannel and named this RegressionChannelRegion and modified the code..

          However, the behavior is the behavior I am demonstrating with the exported script and screenshot, is this correct?
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            Yes, that's exactly what I did. And yes, DrawRegion() as I guess we've both written it is filling in the distance between the linear regression line and the standard deviation line instead of the actual lines plotting. Please let me know if I've misunderstood your question.

            Thanks.

            Comment


              #7
              WhoDat,

              Thank you for confirming that the behavior is what we are after.

              What I had meant in my first reply, is that there isn't a way for us to know what has been added to the script you are testing as this is a custom script created by you (starting as a copy from an existing script).

              Exporting a simplified example will automatically include any indicators called by the script so that someone who may be assisting you can test the exact code you are testing without having to guess at the code you have written or added.

              I have inquired with our development. I will post once I have further information.
              Last edited by NinjaTrader_ChelseaB; 04-17-2017, 07:11 AM.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Gotcha. Please see the attached script and please let me know if there's anything else I can provide.

                Thanks,
                WD
                Attached Files

                Comment


                  #9
                  Hi WD,

                  The Width is not the thickness of the line. This is a multiplier that distances out the upper and lower channels.

                  The default RegressionChannel() uses a width of 2. You are using a width of 4.

                  Change this to a 2 and let me know if this does not resolve the behavior.
                  Chelsea B.NinjaTrader Customer Service

                  Comment


                    #10
                    Hi Chelsea,

                    I'm fully aware of what the width is and have tried both settings. No matter the number chosen, the colored section should still follow a straight line. Here, DrawRegion() is following the actual linear regression line instead of the straight lines used in this indicator. Maybe I should be calling something other than the Middle and Lower dataseries?

                    Thanks,
                    WD

                    Comment


                      #11
                      Hi WD,

                      This is expected.

                      The plots are still there and are set to transparent and have a different value for every bar.

                      There is undocumented code added to the script that draws the lines where they are.

                      Attached is a screenshot showing the plot selection points.


                      If you wanted straight lines, you would need to add new plots that are overwritten on every new bar and calculate the value for that bar based on the slope calculated by the regression.

                      The plots currently are showing what the regression values were on that bar when that bar was the most recent bar.
                      Attached Files
                      Chelsea B.NinjaTrader Customer Service

                      Comment


                        #12
                        Thanks, Chelsea. I won't pretend to fully understand that but I'll certainly look into it.

                        Regards,
                        WD

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by adeelshahzad, Today, 03:54 AM
                        5 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_BrandonH  
                        Started by stafe, 04-15-2024, 08:34 PM
                        7 responses
                        32 views
                        0 likes
                        Last Post NinjaTrader_ChelseaB  
                        Started by merzo, 06-25-2023, 02:19 AM
                        10 responses
                        823 views
                        1 like
                        Last Post NinjaTrader_ChristopherJ  
                        Started by frankthearm, Today, 09:08 AM
                        5 responses
                        22 views
                        0 likes
                        Last Post NinjaTrader_Clayton  
                        Started by jeronymite, 04-12-2024, 04:26 PM
                        3 responses
                        43 views
                        0 likes
                        Last Post jeronymite  
                        Working...
                        X