Hi, I think that my back test product is showing an error. I’d be interested in other people’s views as to whether I’m right, or whether I’m making some fundamental error.
I’ve got a system that is really simple, though it works off a fairly complicated indicator. Here’s the code
Indicator1 = CALL "Basic system 1 + Bollinger"(close)
// Conditions to enter long positions
IF Indicator1 = 1 THEN
BUY 1 CONTRACTS AT MARKET
SET STOP pLOSS 27
SET TARGET pPROFIT 30
ENDIF
// Conditions to enter short positions
IF Indicator1 = -1 THEN
SELLSHORT 1 CONTRACTS AT MARKET
SET STOP pLOSS 27
SET TARGET pPROFIT 30
ENDIF
So, the issue arises when an existing position is in place, and a signal is generated in the opposite direction to the existing position, (ie, i’ve got a long position and a signal is generated which says I should open a short position. My intention was that, in this case, the system should simply close out the existing position and wait for the next opportunity. However, the live system and pro-back test treat this differently. Here’s a case, (AUD/USD 5 minutes) where this happened. (first attachment). When I ran this in live against an IG spreadbetting account, the system behaved as I would expect, the system opened a position at 11:05 and closed it out at 15:40, I’ve attached the transaction history, and you can see that the sell order is opened but immediately nets out against the long position and both then close.
However! when I run a pro-back test over the same period, it not only closes the long position, but it also opens a new short position, giving entirely different results to the live situation. I’ve attached the picture of the pro-back test, and also the detailed results.
Am I being stupid, or is this actually an error in pro-back test.
Any input very gratefully received.
MazParticipant
Veteran
Hiya. Without seeing the indicator code I can’t help. But one or two things are springing to mind.
- Make the logic robust by testing if on market / if longOnMarket / if not shortOnMarkrt etc just to avoid any ambiguity. Explicitly say when it is and when it is not allowed to flip direction. Try elsif where appluckable
- Avoid call. Import your indicator to the system code.
Agree with Maz, you could also GRAPH Indicator1 in backtest to see how really the signals are read by your code.
My first idea would be to completely include your indicator into your automatic strategy code and make new comparison.
thanks both. I’ll try the ideas out. much obliged for the input