stop loss & profit target order settings with the unamanaged approach?
I am developing a new strategy with the unmanaged approach. When I enter a long/short position, I don't know how to exit this position, then set a stop loss order and a profit target order because everytime I run my script below, NinjaTrader doesn't respond.
Here is the script :
public class SStrategy : Strategy
// User defined variables (add any user defined variables below)
private int quantity = 1;
private int target = 30;
/// This method is used to configure the strategy and is called once before any strategy method is called.
protected override void Initialize()
CalculateOnBarClose = true;
Unmanaged = true;
// TraceOrders = true;
/// Called on each bar update event (incoming tick)
protected override void OnBarUpdate()
// Buying condition
if (Close < Bollinger(2, 14).Lower)
longOrder = SubmitOrder(0,OrderAction.Buy,OrderType.Market,quantity,0,0,"","ELong");
Hi stevien - sorry I'm not familiar enough with NT to answer your specific question, but I would have thought that the platform must allow for some sort or bracket order where you automatically set a stop loss and a target?
Regardless of OrderType, you always use SubmitOrder() at least one time. You
always want to save the reference to the IOrder object returned by SubmitOrder.
Then, if you need to update the order later (aka, move the stop, to achieve either
a BreakEven or Trailing effect) you then call ChangeOrder() and pass the saved
reference from SubmitOrder() as the first argument.
So, when entering the stop loss order, you first use SubmitOrder. You save that IOrder
reference returned by SubmitOrder, and use it with ChangeOrder later ... if you need to.
In other words, you would not call ChangeOrder unless you first had an IOrder reference
returned to you from SubmitOrder.