Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Flag for AFTER all drawing objects have fully loaded?

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

    Flag for AFTER all drawing objects have fully loaded?

    Hello.

    I am working with the manually drawn objects on the chart, and pulling information from them.

    Is there an obvious way to not do ANYTHING until the objects have all finished loading(after adding the indicator to the chart)?

    I am working on OnRender(), and I've tried
    Code:
    if(State == State.Historical)
        return;
    Checking the count of DrawObjects also doesn't work, as within OnRender()... Using the count seems unreliable, as on each iteration of onRender... the loop I have process INBETWEEN the onRender iteration.

    What I am looking for, is after the chart fully loads, is the ability to distinguish between when all of the objects have been fully rendered and accounted for by NT... and then everything that occurs AFTER that.

    Is there a simple way to do this?

    #2
    I think I figured it out.

    I have another indicator on the chart, the draws boxes around a certain window of time.

    It appears that OnRender() process the indicator drawn objects BEFORE the manually drawn objects.

    So what was happening, was it would process the latter objects, separately. After figuring this out, I was able to set a flag for when manually drawn objects are found, and THEN do things after that happened.

    Apologies for the thread, this can be deleted if it cleans up the forums.

    Comment


      #3
      Hello forrestang,

      It sounds like you found a solution but just to clarify here, the drawing objects collection which your script has access to is not in sync with the scripts loading so you may see that it is updated later in realtime for your script. The chart loads indicators independently so if the indicator in question that draws the objects takes shorter or longer to load you could see a varied result of finding the objects in your other script.

      The solution would be to actively monitor the collection to find when the object you want is in the collection. You can check the count of the collection as one way to identify when it has items or not and then you could find the object at that point. It sounds like you are doing something similar with the flag you made.

      Comment


        #4
        Howdy.

        I created most of the functionality in OnRender(), but found it quite frustrating as I could not modify various dataSeries from OnRender(). I resorted to recreating bar series with a List, and seeding it the way you might a data series from OnBarUpdate().

        This worked, but eventually got confusing, and have decided to recreate my functionality within OnBarUpdate().

        The issue now is.. .it requires an incoming tick to begin the process when my userDrawn drawobjects are ready.

        One thing I was using this tool for, was to place objects, and have it render lines. The purpose of which was to backtest historical data, and the script just made it easer to place lines. Because it was all in OnRender(), I could place the objects, refresh the chart and the lines would appear.

        However, within OnBarUpdate(), it seems I can only have the script running, WHILE connected to a data feed. Which means, I cannot do this historical checking I want to do, unless I am connected, and the chart must have the current date loaded.

        Is there a way to alleviate this issue given what I want to use it for?

        Comment


          #5
          I might be ok with a one time run of a loop, to seed any series or create the first logic, where I'd just loop over the # of bars.

          But I'd like to have access to the bar and data series, as well as something that would run at least ONCE after loading the chart, and the user drawn drawing objects have loaded.

          Comment


            #6
            Hello forrestang,

            Using OnBarUpdate requires market data events to update so there would not be any way around that. The historical bars will be processed once and then if there is no incoming data it will not call OnBarUpdate. OnRender is called for a variety of reasons related to rendering so that would only be called when manually interacting with the chart if there is no incoming data. Generally its not expected for the script to do anything besides process historical data when there is no live data to continue.

            The draw objects collection is not in sync historically with any indicator so its highly likely that the collection data will only be available while the script is running in realtime, your script will have passed the draw objects collection in processing during historical data processing.

            If you don't have live data and wanted to do something later you could add a custom button and then do your logic within that buttons event. You can wrap the code in the button handler event in a TriggerCustomEvent so that you can use BarsAgo or set plots etc.




            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            27 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            21 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            14 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            11 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            42 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X