Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.Text not showing on chart OnExecutionUpdateAccount

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

    Draw.Text not showing on chart OnExecutionUpdateAccount

    Hello,
    I am trying to add Text and ellipse on chart calling from within OnExecutionUpdateAccount but neither text nor ellipse shows up on the chart. I have tried both Dispatcher.InvokeAsync and direct call (which I knew is incorrect but still tried for completeness). Here is the code snippets. Appreciate any pointer.

    //Dispatcher call
    private void OnExecutionUpdateAccount(object sender, ExecutionEventArgs e)
    {
    if (e.Execution.IsEntry)
    {
    Print("Order executed - Entry detected"); // Debugging
    Dispatcher.InvokeAsync(() =>
    {
    Print("Drawing on UI thread"); // Debugging

    // Use execution price for positioning
    double entryPrice = e.Execution.Price;

    // Draw ellipse and text
    Draw.Ellipse(this, "entryEllipse_" + CurrentBar, true, 0, entryPrice, 10, 10, Brushes.Red, Brushes.Red, 5, true);
    Draw.Text(this, "entryText_" + CurrentBar, "Entry", 0, entryPrice, Brushes.White, null, TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0, true);
    });
    }
    ForceRefresh();
    }

    //Direct call
    private void OnExecutionUpdateAccount(object sender, ExecutionEventArgs e)
    {
    if (e.Execution.IsEntry)
    {
    // Draw the ellipse
    Draw.Ellipse(this, "entry1", true, 1, Close[0], 0, Close[0], Brushes.Red, Brushes.Red, 5);

    // Add text to the chart
    Draw.Text(this, "entryText1", "Entry", 1, Close[0], Brushes.White);

    ForceRefresh();
    }
    }​​

    #2
    Hello dejafutures,

    You are calling a series dependent method outside of a data-driven event.

    You must call TriggerCustomEvent first and this will cause a performance impact.
    Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    160 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Started by CaptainJack, 04-24-2026, 11:07 PM
    0 responses
    307 views
    0 likes
    Last Post CaptainJack  
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    244 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    348 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    178 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Working...
    X