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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    41 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    20 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    29 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    46 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    37 views
    0 likes
    Last Post CarlTrading  
    Working...
    X