I have a Long position and also a Limt order to book my profit. But when i get a trend reversal signal from my indicator, I want to exit my long position. So, I'm calling ExitLong, but it is not working. Am i not allowed to Exit the Long position when i have a pending limit order? Do I need to cancel the existing limit order before I call the ExitLong? Could you please clarify?
//creating entry order based on Buy signal from indicator
EnterLong(quantity, "STScalpLongEntry");
//set limit order with profit target
ExitLongLimit(1, true, quantity, currentPtPrice, "Long profit target", "STScalpLongEntry");
//exit the Long position based on the trend reversal signal
if(Position.MarketPosition == MarketPosition.Long && entryOrder != null)
{
if (entryOrder.Name == "STScalpLongEntry")
ExitLong(quantity,"ExitScalperLongST","STScalpLong Entry");//Exit ST scalper position
}
Thankyou,
Murali

Comment