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 futtrader, 04-21-2024, 01:50 AM
            4 responses
            41 views
            0 likes
            Last Post futtrader  
            Started by Option Whisperer, Today, 09:55 AM
            1 response
            11 views
            0 likes
            Last Post bltdavid  
            Started by port119, Today, 02:43 PM
            0 responses
            7 views
            0 likes
            Last Post port119
            by port119
             
            Started by Philippe56140, Today, 02:35 PM
            0 responses
            7 views
            0 likes
            Last Post Philippe56140  
            Started by 00nevest, Today, 02:27 PM
            0 responses
            7 views
            0 likes
            Last Post 00nevest  
            Working...
            X