I moved a strategy over from NT7 to NT8, and read the code breaking changes related to both OnOrderUpdate and OnExecutionUpdate. I thought I had made the proper code changes, but the compiler is spitting back the following:
'NinjaTrader.NinjaScript.Strategies.PandaVer1.OnOrderUpdate(NinjaTrader.Cbi.Order)': no suitable method found to override 'NinjaTrader.NinjaScript.Strategies.PandaVer1.OnExecutionUpdate(NinjaTrader.Cbi.Execution)': no suitable method found to override
protected override void OnOrderUpdate(Order order)
protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment)
When I tried that, the compiler came back with errors saying that every NT8 local indicator I had (the stock ones that came with an NT8 install) had duplicate indicator values.
Well then, not sure where to go...
-------------
Here's the general structure of the code with a few examples. If anyone has any guidance, I'd love to hear it:
namespace NinjaTrader.NinjaScript.Strategies
{
public class PandaVer1 : Strategy
{
private Order longOrder = null;
private Order shortOrder = null;
protected override void OnOrderUpdate(Order order)
{
// When we determine to stop our strategy all logic in the OnOrderUpdate() method will cease.
if (haltProcessing == true)
return;
// Cancelling long limit orders
if (longOrder != null && longOrder == order // If there's a long order active
&& longOrder.OrderType == OrderType.Limit // and it's a limit order
&& longOrder.OrderState == OrderState.PartFilled // and the order is partially filled
&& // and...
(Close[0] < longOrder.LimitPrice - .15 // the price has gone below the limit order price
|| Close[0] > longOrder.LimitPrice + .15)) // or the price has gone above the limit order price:
{
shares_Amount = longOrder.Quantity; // Reset the shares amount to the current long order quantity
CancelOrder(longOrder); // Cancel the remainder of the order
Print("The limit long order was cancelled. The shares in play are " + shares_Amount + ".");
}
}
protected override void OnExecutionUpdate(Execution execution)
{
/* Long Orders */
if (longOrder == execution.Order && longOrder.OrderState == OrderState.Filled)
{ // do something amazing
}
}
-----------------
Thanks in advance!
Comment