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

Get Drawing Object parameters

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

    Get Drawing Object parameters

    Hello!
    I would like to get a Drawing Object's (which I drawn on chart manually) date and price parameters. I changed the object "Tag" for example "xyz" so I am looking for a method like:
    double price = GetDrawObjectPrice("xyz");
    Is there any such thing?
    Thanks for the answer!

    #2
    Hello snbence,

    You can do this by using the DrawObjects collection. Keep in mind that manually drawn objects are not like script drawn objects, they will not be available in all states of your NinjaScript and can have variable load times which makes the collection variable. Please ensure to read the notes about this collection in the following page.



    Once you have a drawing object instance you can use any of the methods from the instance or cast it to a specific tool type to get specific tool properties.





    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you for your answer.
      I understand that manually drawn objects not always added to the DrawObjects collection. But I am still not sure what to do about it.
      For example if I call Print(DrawObjects.Count); under OnBarUpdate() sometimes it shows the manually drawn objects sometimes not.
      Where should I call it or how to get the actual object count?

      Comment


        #4
        Hello snbence,

        Thank you for the reply.

        Checking the collection will generally only work in realtime so if you are using this from OnBarUpdate you could surround it with a state check:

        Code:
        if(State == State.Realtime)
        {
        
        }
        When you say that it sometimes shows objects are you seeing that it does not for a period such as historical and then will show it going forward in realtime?

        It can also depend on the timing, as this collection is not directly in sync with your script it could have other mis-alignments with OnBarUpdate if you are executing the logic quickly and seeing some kind of delay between drawing and the collection updating.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Hello Jesse,
          Now its working what you suggested to call Print(DrawObjects.Count); under OnBarUpdate() while (State == State.Realtime).
          My problem with this (if I understand right) that its only works when a new bar prints so only when the market is open.
          I am trying to do something for example when I press a button or refresh the chart, I do calculations with the manually created objects on chart.
          Is there any way to do this without OnBarUpdate()?
          I tried to do it like this:

          protected override void OnStateChange()
          {
          if (State == State.SetDefaults)
          {
          ........
          }
          else if (State == State.Realtime)
          {
          Print(DrawObjects.Count);
          }

          }

          But its not worked.
          Thank you for your help!

          Comment


            #6
            Hello snbence,

            At this time there is not a way to reference the collection outside of realtime. You should be able to push a button in realtime and execute this type of logic however it would have to be in realtime while the chart is being updated. You would not have any options for reloading the chart, it would have to wait for your script to enter realtime again to see new objects.



            I look forward to being of further assistance.


            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by maybeimnotrader, Today, 05:46 PM
            0 responses
            6 views
            0 likes
            Last Post maybeimnotrader  
            Started by quantismo, Today, 05:13 PM
            0 responses
            6 views
            0 likes
            Last Post quantismo  
            Started by AttiM, 02-14-2024, 05:20 PM
            8 responses
            167 views
            0 likes
            Last Post jeronymite  
            Started by cre8able, Today, 04:22 PM
            0 responses
            8 views
            0 likes
            Last Post cre8able  
            Started by RichStudent, Today, 04:21 PM
            0 responses
            5 views
            0 likes
            Last Post RichStudent  
            Working...
            X