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
1
2
3
4
5
6
7
8
9
10
11
12
13
Indicator1=CALL"Basic system 1 + Bollinger"(close)
// Conditions to enter long positions
IFIndicator1=1THEN
BUY1CONTRACTSATMARKET
SET STOPpLOSS27
SET TARGETpPROFIT30
ENDIF
// Conditions to enter short positions
IFIndicator1=-1THEN
SELLSHORT1CONTRACTSATMARKET
SET STOPpLOSS27
SET TARGETpPROFIT30
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.
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.
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue