Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Programmatically Save and Re apply Drawing Objects

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

    Programmatically Save and Re apply Drawing Objects

    I know this is beyond the support provided by this forum, but wanted to ask in case someone has already tried this.

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

    I have created a strategy for discretionary trading. When I place trades, the strategy documents the entry and exit with arrows, lines and text.

    The only problem I have now is if I shut the strategy down or shut Ninja Trader down, the mark-ups are gone.

    Is there a way to store and re-apply these discretionary entries/exits? At the moment I can only take snap shots to preserve them, but am looking for a better way.

    I'm thinking saving them is not such a problem but I'm not sure how one would re-apply them. I store the bar number when I place the trade or exit, so the question is how to re-apply the draw object using the stored bar number.

    Thanks,
    taddypole...
    Attached Files

    #2
    Hi taddypole,

    Are these your own custom drawing objects or you refer to NTs built in execution markers? If you are programatically drawing through code, maybe an indicator script will work better for this?

    What are you running into where they would be removed? You can draw though code even on historical bars.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi RyanM,

      My trading is totally discretionary. I have created a control panel with Buy and Sell buttons and thus enter the trades through pure discretion. Also, I've been unsatisfied with the Ninja provided execution markers so have developed my own. When the Market Position changes, after making a trade, I use the DrawText and DrawArrows to put the Trade arrows and associated text on the chart and thus they are not programatically placed.

      If not programatically drawn, they will not be remembered from session to session and thus the reason for saving them through my own code and re-applying them when the chart is reloaded.

      Comment


        #4
        Taddypole, I believe you would need to save all relevant info such as execution prices, data time, barnumber etc in the script (for example to external text file) and then you could rebuild them programmatically for the historical chart part when the script is reloaded.

        Comment


          #5
          The only concern I have is when using tick charts the time stamps are not that reliable. That was my reason for using bar numbers.

          I guess I'm wondering if any one has come up with a definitive definition of uniquely identifying each bar using possibly a time stamp and a bar number reference.

          I thought I remember someone asking this question, but I have not been able to find that thread and when I read it, it was only a question. There was no testing or solution discussed.

          Comment


            #6
            Taddypole, I would not be aware of a solution, as you would need to go lower than 1 sec timestamp then on historical bars for tick based charts.

            Comment


              #7
              Well I am continuing to research this topic, but just have learned something very interesting.

              I have been so frustrated because the PC clock and the data time stamp have never matched. I use Windows 7 64 bit an learned today for the first time that the internet time update was not working. It produced an error.

              An online search revealed that the setting of "time.windows.com" has problems. I updated the site to "time-a.nist.gov" and it updated immediately. The data and the PC clock now match.

              This is great news!...

              Comment


                #8
                Taddypole, correct that can make a difference, great to hear this helps you.

                Comment


                  #9
                  Originally posted by NinjaTrader_Bertrand View Post
                  Taddypole, I believe you would need to save all relevant info such as execution prices, data time, barnumber etc in the script (for example to external text file) and then you could rebuild them programmatically for the historical chart part when the script is reloaded.
                  So I note that in re-applying a drawobject, I would need to specify the Time Parameter. The time parameter will specify the anchor point of the drawobject.

                  It appears that if I record the Time Stamp, I will get a resolution of 1 second. But the question is, what resolution can I specify the Time Parameter in the DrawObject? The "DateTime" has what resolution? I'm guessing it is only down to the minute, is that right? That would be a problem because on a tick chart there can be instances where there are multiple bars per minute.

                  taddypole...

                  Comment


                    #10
                    No, it would be down to 1 second as well then on historical data :

                    Represents an instant in time, typically expressed as a date and time of day.

                    Comment


                      #11
                      Thank you Bertrand,

                      What would the correct format of the Time property in this DrawObject be:

                      DrawText("Test" + CurrentBar, true, "Test", DateTime , Low[0] - 1 * TickSize, 0, Color.White, ObviousBar, StringAlignment.Center, Color.Blue, Color.Black, 2);

                      Can we specify date and time or just time in the DateTime property?

                      Comment


                        #12
                        It needs to be a DateTime object, which includes date and time. General help for working with DateTime is available here:


                        Ryan M.NinjaTrader Customer Service

                        Comment


                          #13
                          Thank you Ryan,

                          I read through the document and now understand the formatting of DateTime values and outputting different string formats.

                          But I still don't understand how to input a value or string. For example, If I wanted to draw a text object at a date of "08/24/2011" and a time of "10:30:03" how would I input that to the DrawText object?
                          Last edited by Taddypole; 08-24-2011, 10:11 PM.

                          Comment


                            #14
                            Taddypole,

                            Are you retrieving your date and times from a condition, or manually inputting these?

                            If it is a manual input, you can specify the exact date time and time by creating a prviate DateTime variable and declaring as below:
                            Code:
                            myTime = new DateTime(2011, 8, 24, 10, 30, 03);
                            
                            DrawText("Test" + CurrentBar, true, "Test", myTime , Low[0] - 1 * TickSize, 0, Color.White, textFont, StringAlignment.Center, Color.Blue, Color.Black, 2);
                            This specifc DateTime Construtor can be found below:



                            More DateTime constructors can be found from the following index:

                            Represents an instant in time, typically expressed as a date and time of day.
                            MatthewNinjaTrader Product Management

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by sjsj2732, Yesterday, 04:31 AM
                            0 responses
                            31 views
                            0 likes
                            Last Post sjsj2732  
                            Started by NullPointStrategies, 03-13-2026, 05:17 AM
                            0 responses
                            286 views
                            0 likes
                            Last Post NullPointStrategies  
                            Started by argusthome, 03-08-2026, 10:06 AM
                            0 responses
                            283 views
                            0 likes
                            Last Post argusthome  
                            Started by NabilKhattabi, 03-06-2026, 11:18 AM
                            0 responses
                            133 views
                            1 like
                            Last Post NabilKhattabi  
                            Started by Deep42, 03-06-2026, 12:28 AM
                            0 responses
                            91 views
                            0 likes
                            Last Post Deep42
                            by Deep42
                             
                            Working...
                            X