Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Compile error "OnExecutionUpdate" and "Draw"

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

    Compile error "OnExecutionUpdate" and "Draw"

    Keep getting compile errors. Any help would be appreciated.

    Click image for larger version  Name:	image.png Views:	0 Size:	7.8 KB ID:	1304937​#region Using declarations
    using System;
    using NinjaTrader.Cbi;
    using NinjaTrader.Gui.Tools;
    using NinjaTrader.NinjaScript;
    using NinjaTrader.Data;
    using NinjaTrader.Gui.Chart;
    using NinjaTrader.NinjaScript.DrawingTools;
    using System.Windows.Media;
    #endregion

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public class FillPriceMinusOpenPrice : Indicator
    {
    private double fillPrice = 0.0;
    private string orderName = "";

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    Description = @"An indicator that posts the value of an order fill price minus the open price of the one-minute bar on the chart.";
    Name = "FillPriceMinusOpenPrice";
    Calculate = Calculate.OnEachTick;
    IsOverlay = true;
    }
    }

    protected override void OnBarUpdate()
    {
    if (CurrentBar < 1)
    return;
    }

    protected override void OnExecutionUpdate(Execution execution, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {
    if (execution.Order != null && execution.Order.OrderState == OrderState.Filled)
    {
    fillPrice = price;
    orderName = execution.Order.Name;

    double openPrice = Open[0]; // Capture the open price of the current bar
    double value = fillPrice - openPrice;

    // Draw the text on the chart
    Draw.Text(this, "OrderFillValue_" + CurrentBar, orderName + ": " + value.ToString("F2"), 0, High[0] + 2 * TickSize, Brushes.White);
    }
    }
    }
    }


    region NinjaScript generated code. Neither change nor remove.

    namespace NinjaTrader.NinjaScript.Indicators
    {
    public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
    {
    private FillPriceMinusOpenPrice[] cacheFillPriceMinusOpenPrice;
    public FillPriceMinusOpenPrice FillPriceMinusOpenPrice()
    {
    return FillPriceMinusOpenPrice(Input);
    }

    public FillPriceMinusOpenPrice FillPriceMinusOpenPrice(ISeries<double> input)
    {
    if (cacheFillPriceMinusOpenPrice != null)
    for (int idx = 0; idx < cacheFillPriceMinusOpenPrice.Length; idx++)
    if (cacheFillPriceMinusOpenPrice[idx] != null && cacheFillPriceMinusOpenPrice[idx].EqualsInput(input))
    return cacheFillPriceMinusOpenPrice[idx];
    return CacheIndicator<FillPriceMinusOpenPrice>(new FillPriceMinusOpenPrice(), input, ref cacheFillPriceMinusOpenPrice);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
    {
    public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
    {
    public Indicators.FillPriceMinusOpenPrice FillPriceMinusOpenPrice()
    {
    return indicator.FillPriceMinusOpenPrice(Input);
    }

    public Indicators.FillPriceMinusOpenPrice FillPriceMinusOpenPrice(ISeries<double> input )
    {
    return indicator.FillPriceMinusOpenPrice(input);
    }
    }
    }

    namespace NinjaTrader.NinjaScript.Strategies
    {
    public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
    {
    public Indicators.FillPriceMinusOpenPrice FillPriceMinusOpenPrice()
    {
    return indicator.FillPriceMinusOpenPrice(Input);
    }

    public Indicators.FillPriceMinusOpenPrice FillPriceMinusOpenPrice(ISeries<double> input )
    {
    return indicator.FillPriceMinusOpenPrice(input);
    }
    }
    }

    #endregion

    Last edited by EminiMES; 05-26-2024, 10:06 AM.

    #2
    I get the same error if I use onorderupdate.....

    Comment


      #3
      Hello EminiMES,

      Thank you for your inquiry.

      Indicators do not have access to strategy methods such as OnExecutionUpdate(), OnOrderUpdate(), etc.

      From an indicator, you could use the AddOn approach to access the AddOn versions OrderUpdate() and ExecutionUpdate().





      Please let us know if you have any further questions.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      605 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      351 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      560 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      561 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X