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

Donchian Channel of MACD

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

    Donchian Channel of MACD

    I am trying to create the indicator referred to in a previous thread
    "http://www.ninjatrader.com/support/forum/showthread.php?t=5314&highlight=donchianchannel+in put"
    but as an beginner, I am not sure how to. Appreciate any help. Thanks.

    Here is the code that I wrote, it compiled without error, but no plot shows up on the chart.

    =================================================
    protected override void Initialize()
    {
    Add(new Plot(Color.Orange, PlotStyle.Line, "myUpper"));
    Add(new Plot(Color.Orange, PlotStyle.Line, "myLower"));
    Overlay = false;
    }

    /// <summary>
    /// Called on each bar update event (incoming tick)
    /// </summary>
    protected override void OnBarUpdate()
    {

    myUpper.Set(DonchianChannel(MACD(12, 26, 9), period).Upper[0]);
    myLower.Set(DonchianChannel(MACD(12, 26, 9), period).Lower[0]);

    }

    ================================================== ===

    #2
    Hello Hank,

    Thank you for your post.

    Are there any errors in the Log tab of the Control Center when applying this to a chart?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      Hello Hank,

      Thank you for your post.

      Are there any errors in the Log tab of the Control Center when applying this to a chart?
      Thanks for the response, Cal.

      Yes, "Error on calling 'OnBarUpdate' method on bar 0 : Index was outside the bounds of the array."

      Comment


        #4
        Hank,

        Try using this in the beginning of your OnBarUpdate()

        if(CurrentBar < BarsRequired) return;
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          Hank,

          Try using this in the beginning of your OnBarUpdate()

          if(CurrentBar < BarsRequired) return;
          Thanks Cal.

          Still got the same error message... on bar 20 instead of bar 0.
          "Error on calling 'OnBarUpdate' method on bar 20 : Index was outside the bounds of the array."

          Comment


            #6
            Hank,

            Is there anything else in the script besides what you have posted?

            I tested just what you posted on my end and worked fine.

            Does the error give an indicator name by any chance for the OnBarUpdate error?
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              I am still getting same error message. Nothing else on the script.

              Yes, the error message does give the name of the indicator. Sorry, I neglected that part..

              Attached is the picture of the chart that I got and exported indicator.
              Attached Files

              Comment


                #8
                Hank,

                How many days to load are you using for the chart?

                You may need to load more by right clicking in the chart and selecting DataSeries... and increase the Days to load parameter
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  There is a bug in the Properties region. You need to start counting with 0, not with 1. Please change the code to:

                  Code:
                  [Browsable(false)]
                   XmlIgnore()]
                  public DataSeries myUpper
                  {            get { return Values[0]; }
                  } 
                          
                  [Browsable(false)]
                  [XmlIgnore()]
                  public DataSeries myLower
                  {
                     get { return Values[1]; }
                  }

                  Comment


                    #10
                    Originally posted by Harry View Post
                    There is a bug in the Properties region. You need to start counting with 0, not with 1. Please change the code to:

                    Code:
                    [Browsable(false)]
                     XmlIgnore()]
                    public DataSeries myUpper
                    {            get { return Values[0]; }
                    } 
                            
                    [Browsable(false)]
                    [XmlIgnore()]
                    public DataSeries myLower
                    {
                       get { return Values[1]; }
                    }
                    Yes, that solves the problem... I copied that part of code from Donchian script.. Thanks Harry...

                    Cal, thanks for your effort as well. I appreciate it.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by stafe, 04-15-2024, 08:34 PM
                    7 responses
                    31 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by adeelshahzad, Today, 03:54 AM
                    4 responses
                    29 views
                    0 likes
                    Last Post adeelshahzad  
                    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
                    17 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