My strategy has multiple entries and multiple exits, something similar with the following code:
protected override void OnBarUpdate()
{
// Entry condition 1
if (CrossAbove(SMA(10), SMA(20), 1))
EnterLong("Condition 1 Entry");
// Entry condition 2
if (CrossAbove(RSI(14, 3), 30, 1))
EnterLong("Condition 2 Entry");
// Closes the position created by entry condition 1
if (CrossBelow(SMA(10), SMA(20), 1)
ExitLong("Condition 1 Entry");
// Closes the position created by entry condition 2
if (CrossBelow(RSI(14, 3), 70, 1))
ExitLong("Condition 2 Entry");
}
Actually I have 5 different entries and 4 different exits. Like halfway through my backtesting I am getting the following error message:"Error on running backtest:Object reference not set to an instance of an object" and the backtest ends.
Looking through Orders Tab I see one order with State "Working" and Action is "Buy to cover". My strategy is Long only! Checking the Trades tab I see that trades triggered by say "Condition 1 Entry" are exited by 2nd or 3rd exit condition or even 4th! Looks like it doesn't matter what "fromEntrySignal" parameter is if the exit condition is true(for that specific instrument) the software sells the entire position!.
I thought that no matter what the exit condition is if I use "fromEntrySignal" parameter NT will close only the position(with the quantity) associated with that specific EntrySignal!
Please clarify.
Thank you,
Dan

Comment