For example, if we are short and the last bar closes over the SMA, then Ninja sends two stop orders, one to close the short position and the other to open a long position.
If the orders are filled, there is no problem and ninja runs the strategy correctly.
But if the price doesn’t reach the stop, and one of the following bars crosses below the SMA, then Ninja should cancel the two orders, but in fact it only cancel the open long position order, not the close short position order.
Is there any way to solve this?
I have programmed the strategy by the wizard, here is the code:
///</summary>
protectedoverridevoid Initialize()
{
Add(SMA(SMAperiod));
CalculateOnBarClose = true;
}
///<summary>
/// Called on each bar update event (incoming tick)
///</summary>
protectedoverridevoid OnBarUpdate()
{
// Condition set 1
if (Close[0] > SMA(SMAperiod)[0])
{
EnterLongStop(DefaultQuantity, Close[0] + 4 * TickSize, "");
}
// Condition set 2
if (Close[0] < SMA(SMAperiod)[0])
{
EnterShortStop(DefaultQuantity, Close[0] + -4 * TickSize, "");
}


Comment