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 argusthome, 03-08-2026, 10:06 AM
    0 responses
    68 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    41 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    24 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    27 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    54 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X