• 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

Make lines drawn by indicator static

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

    Make lines drawn by indicator static

    I am reposting this here...originally posted in wrong forum

    I have created an indicator that posts a dialog box allowing me to enter a single value for a horizontal line using the Drawline funtion. This saves me a lot of mouse clicks required when using the drawing tool.

    The problem is the lines disappears if I refresh the chart to restart Ninja. Is there a way to flatten the chart after I draw the line making it part of the chart?

    Thanks!

    #2
    Originally posted by buschkt View Post
    I am reposting this here...originally posted in wrong forum

    I have created an indicator that posts a dialog box allowing me to enter a single value for a horizontal line using the Drawline funtion. This saves me a lot of mouse clicks required when using the drawing tool.

    The problem is the lines disappears if I refresh the chart to restart Ninja. Is there a way to flatten the chart after I draw the line making it part of the chart?

    Thanks!
    How many lines do you have?

    Suppose there are just several lines. Please save the price of each line as a "double" property (in the indicator settings dialog). When the platform and chart start, you have the price of the line to draw.

    Regards,
    Pi
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment


      #3
      Please see my response at the following link: http://www.ninjatrader.com/support/f...80&postcount=2
      Patrick H.NinjaTrader Customer Service

      Comment


        #4
        I can draw up to a dozen or more lines in a day and would like to keep the historical lines I have drawn. I was hoping there was a method to convert the drawing object to the chart xml.

        If there is not a way to do this in Ninja I may create my own database and log the values there.....

        I don't like all the mouse clicks required to draw a simple line. It would help if only one price value was required instead of the beginning and the end. Maybe a checkbox the ties them together.

        Thanks

        Comment


          #5
          Originally posted by buschkt View Post
          I can draw up to a dozen or more lines in a day and would like to keep the historical lines I have drawn. I was hoping there was a method to convert the drawing object to the chart xml.

          If there is not a way to do this in Ninja I may create my own database and log the values there.....

          I don't like all the mouse clicks required to draw a simple line. It would help if only one price value was required instead of the beginning and the end. Maybe a checkbox the ties them together.

          Thanks
          That is a good solution. Write data to a file and read data from that file to draw lines when charts restart /refresh.

          Alternatively, you can make a public property which is double array or a List<double>. They will be serialized to survive platform restarts.

          If you want to use a double array (fixed size, so make it 30 elements for example):
          Code:
          double[] dataArray = { 0, 0, 0, 1, 2, 3, 4, 5 };
          
          [GridCategory("Parameters")]
                  public double[] DataArray {
                      get { return dataArray; }
                      set { dataArray = value; }
                  }
          If you want to use a List<double> (dynamic size, automatically expand on the fly):
          Code:
          using System.Collections.Generic;
          
          List<double> dataList = new List<double>();
          
          [GridCategory("Parameters")]
                  public List<double> DataList {
                      get { return dataList; }
                      set { dataList = value; }
                  }
          Screenshots for both solutions are attached.

          The rest is how well you manage the array or list to save the prices of the lines.

          Thanks.
          Pi
          Attached Files
          Last edited by ninZa; 12-22-2014, 07:43 PM.
          ninZa
          NinjaTrader Ecosystem Vendor - ninZa.co

          Comment


            #6
            IMO writing data to a file is the last solution to consider.
            ninZa
            NinjaTrader Ecosystem Vendor - ninZa.co

            Comment


              #7
              Thanks for the great idea....

              I am writing all the Drawline parameters to a file and reading them in the StartUp function.

              Works great!!!!!!!!!!!!

              Thanks

              KB

              Comment


                #8
                Alternatively, you can make a public property which is double array or a List<double>. They will be serialized to survive platform restarts.
                Hey ninZa

                That's fascinating about Arrays and Lists. I've tried to use these once or twice but it's never worked!

                Could you kindly explain what 'serialized' means in this context?

                Thanks in advance.

                Comment


                  #9
                  Originally posted by arbuthnot View Post
                  Hey ninZa

                  That's fascinating about Arrays and Lists. I've tried to use these once or twice but it's never worked!

                  Could you kindly explain what 'serialized' means in this context?

                  Thanks in advance.
                  I mean they will be saved and recovered every time charts refresh or NinjaTrader restarts.

                  This may be different from the standard definition of serialization, because I'm actually not a C# guru.

                  Happy holidays!
                  Pi
                  ninZa
                  NinjaTrader Ecosystem Vendor - ninZa.co

                  Comment


                    #10
                    Originally posted by ninZa View Post
                    I mean they will be saved and recovered every time charts refresh or NinjaTrader restarts.

                    This may be different from the standard definition of serialization, because I'm actually not a C# guru.

                    Happy holidays!
                    Pi
                    Thanks very much, ninZa.

                    You mentioned 'standard definition': this is what I came across by way of a MSFT/C# definition:

                    Serialization is the process of converting an object into a stream of bytes in order to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.
                    which is effectively what you stated.

                    I'd seen this before in the Forum and I was completely baffled by it.

                    Hope you and other users are having a great holiday!

                    Ed

                    Comment


                      #11
                      Originally posted by arbuthnot View Post
                      Thanks very much, ninZa.

                      You mentioned 'standard definition': this is what I came across by way of a MSFT/C# definition:

                      which is effectively what you stated.

                      I'd seen this before in the Forum and I was completely baffled by it.

                      Hope you and other users are having a great holiday!

                      Ed
                      Wow. So my own understanding of serialization is actually correct

                      Thank you for being active and supportive in many threads here.

                      All the best to you and the whole NT community!
                      Pi
                      ninZa
                      NinjaTrader Ecosystem Vendor - ninZa.co

                      Comment


                        #12
                        My line drawing indicator is working great. Now I would like to add some functionality to update the file when a line is changed via the normal chart interface. I would like to compare what is in the file to the current values and update file if needed.

                        I only see the DrawObject "type" not the tag value when I list the draw objects. Is there a way to get the tag value or better yet is there a callback function that would alert me to a change?

                        Thanks again!!

                        Happy New Year!!

                        Comment


                          #13
                          Hello buschkt,

                          Thanks for your post.

                          You will need to cast the object to the drawing object type to find the tag.

                          For example:

                          Code:
                          foreach(IDrawObject draw in DrawObjects)
                          {
                          if (draw.DrawType == DrawType.HorizontalLine)
                          {
                          IHorizontalLine hLine;
                          hLine = (IHorizontalLine) draw;
                          if (hLine == null)
                          return;
                          Print(hLine.Tag);
                          }
                          }
                          Chelsea B.NinjaTrader Customer Service

                          Comment


                            #14
                            Thanks!!! That worked great!!!!!!!!!!!!!

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by dshalom9, Today, 08:36 AM
                            9 responses
                            8 views
                            0 likes
                            Last Post NinjaTrader_PatrickG  
                            Started by stock_wizard_49, 07-11-2020, 06:57 PM
                            1 response
                            16 views
                            0 likes
                            Last Post NinjaTrader_PaulH  
                            Started by asmmbillah, Yesterday, 03:03 PM
                            1 response
                            9 views
                            0 likes
                            Last Post NinjaTrader_Jesse  
                            Started by AspenHiker, Today, 08:37 AM
                            0 responses
                            5 views
                            0 likes
                            Last Post AspenHiker  
                            Started by StarTrader, 07-11-2020, 11:27 AM
                            2 responses
                            19 views
                            0 likes
                            Last Post StarTrader  
                            Working...
                            X