View Full Version : ExitLongStop not executed
ali321
03-05-2010, 02:55 PM
Hallo,
I'm testing some simple strategies, does anybody see why the Enter works fine, but the ExitLongStop is never executed ?
regards Ali
if (ADX(14)[0] > 25
&& Close[0] < SMA(10)[0]
&& Close[0] > EMA(30)[0]
&& 1 == Swing(0).SwingLowBar(0, 1, 10))
{
EnterLong(DefaultQuantity, "");
}
ExitLongStop(Swing(1).SwingLow[0], "StopExit", "");
ali321
03-05-2010, 03:15 PM
if (ADX(14)[0] > 25
&& Close[0] < SMA(10)[0]
&& Close[0] > EMA(30)[0]
&& 1 == Swing(0).SwingLowBar(0, 1, 10))
{
EnterLong(DefaultQuantity, "");
}
if (Low[0] < Swing(1).SwingLow[0]){
ExitLong("Exit Long", "");
}
This excample works, buts not the same like an exitstoplong order.
NinjaTrader_Josh
03-05-2010, 03:23 PM
ali321,
When you submit stops or limit orders you need to keep them alive on every single sequential bar otherwise they will auto cancel. To keep them alive, you need to call ExitLongStop() again with the same quantity, price, and name and it will keep the order alive.
ali321
03-05-2010, 03:29 PM
ali321,
When you submit stops or limit orders you need to keep them alive on every single sequential bar otherwise they will auto cancel. To keep them alive, you need to call ExitLongStop() again with the same quantity, price, and name and it will keep the order alive.
Sorry, I don't understand how the code should look like.
Do you have an excample ?
NinjaTrader_Josh
03-05-2010, 03:48 PM
ali321,
I have no code example I can provide you as it is highly dependent on what logic you want to put into place. All you need to do is decide when you want to cancel the order if it still doesn't fill. Then create an if-statement
if (Position.MarketPosition == MarketPosition.Long && some other conditions)
ExitLongStop(...);As long as your other conditions are true you will try to keep the stop order alive. When it is false, you stop and then the order is cancelled.
ali321
03-06-2010, 09:38 AM
Hallo,
does anyone know a link or support thread where the handling of the ExitLongStop is explaint better then in the programming help system ?
regards ali
NinjaTrader_Austin
03-06-2010, 12:57 PM
Ali, another option would be to specify that these orders are live until cancelled. That way you won't have to keep re-submitting the orders.
//ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)
ExitLongStop(0, true, 1, Swing(1).SwingLow[0], "StopExit", "");