Here's the code:
region Using declarations
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using NinjaTrader.Cbi;
using NinjaTrader.NinjaScript;
using NinjaTrader.Data;
using NinjaTrader.Gui.Tools;
#endregion
namespace NinjaTrader.NinjaScript.Strategies
{
public class BracketValueStrategy : Strategy
{
private double stopDollarValue;
private double profitDollarValue;
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Stop Loss Ticks", Order = 1, GroupName = "Parameters")]
public int StopLossTicks { get; set; }
[NinjaScriptProperty]
[Range(1, int.MaxValue)]
[Display(Name = "Profit Target Ticks", Order = 2, GroupName = "Parameters")]
public int ProfitTargetTicks { get; set; }
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "Displays the dollar value of the bracket stop and profit levels.";
Name = "BracketValueStrategy";
Calculate = Calculate.OnEachTick;
}
}
protected override void OnBarUpdate()
{
if (Position.MarketPosition == MarketPosition.Flat)
return;
double entryPrice = Position.AveragePrice;
double stopPrice = entryPrice - (StopLossTicks * TickSize);
double profitPrice = entryPrice + (ProfitTargetTicks * TickSize);
stopDollarValue = (entryPrice - stopPrice) * Instrument.MasterInstrument.PointValue;
profitDollarValue = (profitPrice - entryPrice) * Instrument.MasterInstrument.PointValue;
Print($"Stop Value: ${stopDollarValue:N2}");
Print($"Profit Value: ${profitDollarValue:N2}");
Print($"Stop Level: {stopPrice}, Profit Level: {profitPrice}");
}
// ✅ Fully Corrected OnOrderUpdate Method
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, OrderState orderState, DateTime time)
{
if (order == null) return;
Print($"Order Update - ID: {order.OrderId}, State: {orderState}, Time: {time}");
}
// ✅ Fully Corrected OnExecutionUpdate Method
protected override void OnExecutionUpdate(Execution execution, Order order)
{
if (execution == null || order == null) return;
Print($"Execution Update - Order ID: {order.OrderId}, Price: {execution.Price}, Quantity: {execution.Quantity}");
}
}
}
This is the error codes I'm getting:
NinjaScript File,Error,Code,Line,Column,
BracketValueIndicator.cs,'BracketValueStrategy.OnO rderUpdate(Order double double OrderState)': no suitable method found to override,CS0115,56,33,
BracketValueIndicator.cs,'BracketValueStrategy.OnE xecutionUpdate(Execution Order)': no suitable method found to override,CS0115,64,33,

Comment