View Full Version : Handling of Exit Long and Exit Short before EOD
Trader Rob
10-22-2007, 01:30 PM
In the condition builder I check for ToTime>21:45 and want as action to close my position. Can I give the ExitLong as well as the ExitShort command at the same time? What will be the result of the ExitShort command when you have a Long position or no position?
Is there a smarter way to close your position indepent it is Long or Short?
woodside
10-22-2007, 02:04 PM
this is what I do:
if (Position.MarketPosition != MarketPosition.Flat) {
if (Position.MarketPosition == MarketPosition.Long) {
//exit long code here
}
if (Position.MarketPosition == MarketPosition.Short) {
//exit short code here
}
}
NinjaTrader_Ray
10-22-2007, 02:07 PM
Yes, you can have both. One or both are ignored if a position does not exist to be closed.
The help for ExitShort (http://www.ninjatrader-support.com/HelpGuideV6/helpguide.html?ExitShort) says "This method is ignored if a short position does not exist", so it should be OK to just issue both the ExitShort and the ExitLong when you want to flatten your strategy.