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:	163
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, 12:25 PM.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by gemify, 11-11-2022, 11:52 AM
            6 responses
            803 views
            2 likes
            Last Post ultls
            by ultls
             
            Started by ScottWalsh, Today, 04:52 PM
            0 responses
            3 views
            0 likes
            Last Post ScottWalsh  
            Started by ScottWalsh, Today, 04:29 PM
            0 responses
            7 views
            0 likes
            Last Post ScottWalsh  
            Started by rtwave, 04-12-2024, 09:30 AM
            2 responses
            22 views
            0 likes
            Last Post rtwave
            by rtwave
             
            Started by tsantospinto, 04-12-2024, 07:04 PM
            5 responses
            70 views
            0 likes
            Last Post tsantospinto  
            Working...
            X