Most trades are only 1 bar long, so it buys at open and sells at close of the same bar. There are many double buy and sell conditions that I could remove with
Buy=ExRem(Buy,Sell);
Sell=ExRem(Sell,Buy);
I have 2 questions and hope someone could help me a bit or show me a link what I should study.
If I use exrem, the trades that take from open till close on the same bar do not occur anymore and those are the most usefull trades in this case. I understand that is the consequence of using exrem. Is there a way to prevent double trades and still allow the trades that buy at open and sell at close of the same bar? Maybe I should not call it double trades see second question.
Second question is this case: when not using exrem if a trades starts at bar open for example at bar 100 and takes till close bar 105 and another new trade occurs at bar open 105 till close bar 105, there are 2 open positions at the same time. I see these 2 trades occuring in this case while Numpos =1.
I also see it back in the exposure of the backtest results. How could I prevent this second trade to happen without using exrem and using 1 max openposition?
@PWFores I'm not sure I understand your problem (and it almost always helps to see your code to understand what is going on). You can't successfully use exrem but I don't understand why without the underlying logic of the signals.
Also it may help if you read carefully the section on "RESOLVING SAME BAR, SAME SYMBOL SIGNAL CONFLICTS" when you scroll down this page,
In backtest ExRem is not required because default backtest mode is backtestRegular. And that one removes redundant signals per symbol already. And as you might have noticed I said ExRem is per symbol's array function but not function to remove signals of two or more symbols of portfolio backtest.
You may use Custom Backtester checking for open positions and signals and counting and signal skipping.
Without Custom Backtest code
With CBT code included -> MSFT trade skipped on July 16th
Yes that situation is exactly what I mean. See my picture.
It exits at the close of the 16:00 bar but it also opens at the open
of 16:00 bar so 2 positions are active in that bar.