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

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.
    Gaby V.NinjaTrader Customer Service

    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
        Gaby V.NinjaTrader Customer Service

        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
            Gaby V.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by llanqui, Today, 03:53 AM
            0 responses
            6 views
            0 likes
            Last Post llanqui
            by llanqui
             
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            10 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            15 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            14 views
            0 likes
            Last Post strategist007  
            Working...
            X