Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Open/Close of a bar on another chart?

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

    #16
    Hi Dave,

    Here is the code, I hope!
    Please let me know if you can open it.

    Thanks,
    DT_12
    Attached Files

    Comment


      #17
      Hello,

      It looks like you were only missing one small piece -- a CurrentBar check. In the NinjaScript Output Window, your script was sending the following error message:

      Error on calling 'OnBarUpdate' method for indicator 'Open15' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart
      To resolve this, I added the following check:

      Code:
      If (CurrentBar < 5) return;
      to cause the indicator to not run any calculations until the fifth bar in the data series. I've uploaded a new version of Open15 for you, and I've also replaced the horizontal line with a Ray in the code.
      Attached Files
      Dave I.NinjaTrader Product Management

      Comment


        #18
        Hi Dave,

        I got the code, thank you!
        I need to add the width to the code.
        I don't see how from the link you sent me.
        I want the width to be a 3 by default.
        Actually, inputs for color, width,style would even be better.

        Thanks again,

        DT_12
        Last edited by DayTrader12; 06-12-2015, 02:25 PM.

        Comment


          #19
          Hello,

          The constructor overload that I mentioned in post #13 on this thread takes all three of those parameters. I don't think I used that particular overload in my example code, but here is the method signature for your reference:

          DrawRay(string tag, bool autoScale, DateTime anchor1Time, double anchor1Y, DateTime anchor2Time, double anchor2Y, Color color, DashStyle dashStyle, int width)

          Here is a real-world example using a solid style, green color, and a width of 3:

          Code:
          DrawRay("ray", false, Time[1], Close[1], Time[0], Close[0], Color.Green, DashStyle.Solid, 3)
          Dave I.NinjaTrader Product Management

          Comment


            #20
            No luck adding the width gets me this error message:

            The following CS1501 error code information is provided within the context of NinjaScript. The examples provided are only a subset of potential problems that this error code may reflect. In any case, the examples below provide a reference of coding flaw possibilities.



            Error Code Explanation

            This error can occur when you use use an overload (method parameter signature) that does not exist. This could either be because you are passing in 3 arguments when the method only requires 2.



            You can cycle through the available overloads with the use of the up and down arrows on the Intellisense when you call an indicator method or any other method.
            Last edited by DayTrader12; 06-12-2015, 03:25 PM.

            Comment


              #21
              Can you paste the code that you are using to try to draw the ray, so I can double check it?
              Dave I.NinjaTrader Product Management

              Comment


                #22
                DrawRay("ray",1,Opens[1][0],0,Opens[1][0],Color.Blue, DashStyle.Solid, 3)

                Comment


                  #23
                  BTW, you are awesome for all this help.
                  I just bought this ebook to read this weekend:
                  NinjaScript Programmer's Launch Pad by Scott Daggett.
                  Here is a big fan of your support, btw.
                  Last edited by DayTrader12; 06-12-2015, 03:43 PM.

                  Comment


                    #24
                    Thank you -- I see what the issue is. You will need to carefully ensure that you are providing everything that the method signature calls for. The signature calls for the following parameters:

                    DrawRay(string tag, bool autoScale, DateTime anchor1Time, double anchor1Y, DateTime anchor2Time, double anchor2Y, Color color, DashStyle dashStyle, int width)

                    In your code, you are passing in a string, bool, double, int, double, Color, and DashStyle. But you need to pass in a string, bool, DateTime, double, DateTime, double, Color, then DashStyle.

                    Here's a tip for you -- to obtain a DateTime object pegged to a certain bar, you can use Times[][] the same way you are using Opens[][]. So, to obtain a DateTime object pegged to the same bar as Opens[1][0], you can use Times[1][0].

                    If you take a look at the sample in my previous post, this should provide a guide for you. Or, feel free to just copy and paste the method signature itself into your code, and then you can replace one parameter at a time with your input.
                    Dave I.NinjaTrader Product Management

                    Comment


                      #25
                      Hi Dave,

                      I see from the Ninja programming book I bought, that I need more understanding of C# in order to code indicators and strategies. I am now trying to learn C# so as to correct my code from the websites suggested in the ebook which are print based.
                      Any suggestions on good C# basic resources for visual learners like myself?

                      In the meantime, can you please post a corrected version of my code for the
                      open,high,low,close of the previous 15 minute candle on a 3 minute chart with the ability to change the style, width, and colors as inputs?
                      With TS, I would only have the ability to change all of these from a format window outside of the code.

                      Appreciate it.

                      DT_12

                      Comment


                        #26
                        Hello,

                        Can you please share a link to the book you've purchased? It may be useful for our team, and I'm curious to take a look at it.

                        As far as C# resources go, here are two resources that we really like on the NinjaScript team:

                        http://www.dotnetperls.com/

                        http://li153-236.members.linode.com/...harp/index.php

                        I'm not sure what else I can provide in terms of the code examples. I've laid out the proper constructor overloads for the drawing method in posts 13, 19, and 24 of this thread, and provided a working example in post 19 of this thread. This thread also contains all of the information necessary to add a secondary data series and plot the drawing object based on that secondary series. If you can specify exactly what is unclear about the information already posted, I'll do my best to clarify.
                        Dave I.NinjaTrader Product Management

                        Comment


                          #27
                          Hi Dave,

                          Here is the link for the ebook I bought to help me code Ninja Trader:

                          NinjaScript C# programming tutorial ebook available on Smashwords.com


                          I will try to code the lines after I learn what C# is all about.

                          Take care,

                          DT_12

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          576 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          334 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          101 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          553 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          551 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X