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

Draw methods inside OnExecutionUpdate

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

    Draw methods inside OnExecutionUpdate

    Hi All,

    Do the draw methods not work inside events like OnExecutionUpdate?

    For instance, I put in a quick hack for some visuals with a line like this

    Draw.Line(this,"TradeLine"+lastEntryBar,false,Curr entBar0-lastEntryBar,Price,0,e.Execution.Price,Brushes.Gra y,DashStyleHelper.Dash,2);

    The bars back is CurrentBar0=7606 lastEntryBar=7596, so 10. The prices are correct. The line does not show on the chart. I check in the drawing objects - It is there with correct prices, but start and end times are off the beginning of the chart. I know there are some sync issues using bar[0] etc in these events, but I thought somehow this one would work? Note - I'm not using currentbar. Currentbar0 is set to currentbar within OnBarUpdate. Time of trade was 13th, @ 05:58.

    Thanks.
    Click image for larger version

Name:	NinjaTrader_CWw9hAfeGr.png
Views:	51
Size:	12.5 KB
ID:	1176010

    #2
    Hello pjsmith,

    Draw methods can be called from OnExecutionUpdate().

    If the object is appearing in the Draw Objects window, then it has been drawn.

    What brush / color is the Draw Objects window showing for this object?

    What does the chart look like showing 11/10/2021 21:39 to 23:00 from 14635 to 14637.5?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi,

      Thanks for the reply.

      So, I'd disabled the code as it was not working. Just added it back in and tested it on another clean 100 tick chart. I get this

      From the debug output

      CurrentBar0=936 lastEntryBar=923

      The 2 lines of code are like this, one after the other (actual code)

      Print("CurrentBar0="+CurrentBar0+" lastEntryBar="+lastEntryBar);
      Draw.Line(this,"TradeLine"+lastEntryBar,false,Curr entBar0-lastEntryBar,Price,0,e.Execution.Price,Brushes.Dim Gray,DashStyleHelper.Dash,2);

      And I get this for the drawing object properties (it is drawn, just at the wrong times - it does not appear on the chart as it is beyond the start time of the chart dataseries)

      Click image for larger version  Name:	EpicPen_wUOECj785L.png Views:	0 Size:	37.3 KB ID:	1176291

      Here is the extreme left of my chart (with the middle mouse held down so you can see time)

      Click image for larger version  Name:	EpicPen_X1UyzqoJ3B.png Views:	0 Size:	26.8 KB ID:	1176290

      I'm obviously missing something here, but I can't see it! It seems the 'barsago' to add the line is not working. The 7 bars ago it should have printed would be rather more to the right!

      Thanks.

      Comment


        #4
        Hello pjsmith,

        Simplify your testing...

        May I have you move the code for this one drawing object to a new script and test this on a new chart without other drawing objects and plots?
        I can't see the date on the chart to confirm this is the right bar.. May we see the entire chart with the dates visible on the time scale?
        I can't see the price on the chart to confirm this is right price.. May we see the entire chart with the dates visible on the price scale?

        It looks like you have Oct 25th on the chart, while the line is drawn from August 5th to August 19th. We want to confirm you are looking at August 19th on the chart where we should see one end point at 1:44 PM at a price of 15120.75.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Sorry, but no idea why this is not working. I can;t see the issue. I copied the price values into a list instead and mark them up in OnRender. Works fine. Draw.Line was a quick hack to test the idea. For whatever reason, it does not work as expected for me.

          Comment


            #6
            Hello pjsmith,

            To assist I need the information requested in post #4.

            I suspect you are not looking at the chart where the drawing object is an that the object is indeed being drawn.

            Further, I think the lines are not being drawn you are expecting. (So possibly drawn at the wrong time or with the wrong barsAgo values)
            Last edited by NinjaTrader_ChelseaB; 10-26-2021, 11:25 AM.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fafafdenis, Today, 04:56 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_EricB  
            Started by pjsmith, 07-18-2019, 04:21 AM
            7 responses
            249 views
            0 likes
            Last Post aligator  
            Started by ark321, Today, 05:12 PM
            0 responses
            11 views
            0 likes
            Last Post ark321
            by ark321
             
            Started by futurenow, Today, 04:49 PM
            0 responses
            9 views
            0 likes
            Last Post futurenow  
            Started by ofer1964spivak, Today, 04:27 PM
            0 responses
            5 views
            0 likes
            Last Post ofer1964spivak  
            Working...
            X