Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Drawing using OnMarketData

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

    Stop Drawing using OnMarketData

    I have an indicator that draws a rectangle on meeting a condition using OnBarUpdate. Instead of waiting for the bar to close, I tried using the OnMarketData to initiate the drawing as soon as price met my condition but the bar had not yet closed.

    The OnBarUpdate will successfully draw the rectangle after the bar has closed so this is working as expected.

    The OnMarketData, which is much different from the OnMarketUpdate does begin drawing the rectangle as expected, but continues modifying the the rectangle after the bar closed.

    #2
    Hello Itachi,

    Thank you for your post.

    Are you using unique tag names to draw a new rectangle each time , or are you reusing the tag name to update an existing drawing object?

    To give a drawing object a unique tag name, please see the forum post linked below:



    Please let me know if I can assist further.

    Comment


      #3
      I'm using text+CurrentBar

      Comment


        #4
        Hello,

        What are the conditions you are using to call the draw method?

        Please see the attached script demonstrating drawing in OnMarketData(). Using a unique tag name, the drawing object is not updated after it has been created.
        Attached Files

        Comment


          #5
          Pick any condition you like. Would I would like to happen is when the condition is met in OnMarketData it draws a rectangle and continues to update the rectangle size. When the bar closes I would like the rectangle to stop updating

          ex OnMarketData: if (maketDataUpdate.last > Close[1] ) Draw/update rectangle

          ex OnBarUpdate: if(Close[0] > Close[1]) Draw final rectangle

          Comment


            #6
            Hello,

            We suggest using a bool. In OnMarketUpdate(), require the bool to be true and in OnBarUpdate(), set the bool to false based on your condition to stop updating the drawing.

            See the attached sample script below, which moves a rectangle up until the bar closes.

            Please note this script is using Calculate.OnPriceChange, so OnBarUpdate() also checks if IsFirstTickOfBar is true to make sure this happens once per bar.

            If you have any questions, please let us know.
            Attached Files

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            581 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            337 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            103 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            554 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            552 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X