• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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 bouncetherubble, Yesterday, 08:42 PM
                    1 response
                    11 views
                    0 likes
                    Last Post NinjaTrader_ChrisL  
                    Started by bortz, Yesterday, 08:18 AM
                    5 responses
                    35 views
                    0 likes
                    Last Post bortz
                    by bortz
                     
                    Started by GARZONJ, Yesterday, 09:02 PM
                    1 response
                    15 views
                    0 likes
                    Last Post NinjaTrader_ChrisL  
                    Started by siroya, Today, 06:32 AM
                    4 responses
                    19 views
                    0 likes
                    Last Post NinjaTrader_ChrisL  
                    Started by cstern71, 09-02-2019, 10:30 AM
                    2 responses
                    40 views
                    0 likes
                    Last Post tgn55
                    by tgn55
                     
                    Working...
                    X