I have reimplemented some old code for tracking profit. It was originally implemented to help debug some code for trailing multiple trades per pair and it got neglected after I abandoned that method of trailing.
It was not designed to be safe for real time forward testing. However, the new version is designed for both forward and back-testing, but it cannot be used while trading more than one trade per pair until I start using classes and objects as it would be too cumbersome to do it in simple script.
It should now be possible to cross compare the the real-time results against the back-test and also find out exactly how the jumping stop losses and profit lock exits can be improved.
With reference to the earlier post for USDJPY, this is how the profit tracking looks shortly after the entry:
Code: Select all
04:30 USDJPY: : 1 $MxPf:10.71 $RPf: 7.33 Pips:4.60 $DdBp:-2.55 $DdAp:0.00 GapTp:23.10
where
$MxPf: Maximum money profit so far
$RPf: Snapshot of current money profit
Pips: Snapshot of profit in pips
$DdBp: How much the trade reversed before getting into profit
$DdAp: How much the trade reversed after it went into profit
GapTp: Snapshot of current number of pips away from the take profit price
so this extract shows the trade getting to within one pip of the take profit price:
Code: Select all
424: 05:16 USDJPY: : 1 $MxPf:53.81 $RPf: 53.81 Pips:21.10 $DdBp:-2.55 $DdAp:0.00 GapTp:6.60
425: 05:17 USDJPY: : 1 $MxPf:53.81 $RPf: 48.47 Pips:19.20 $DdBp:-2.55 $DdAp:0.00 GapTp:8.50
426: 05:18 USDJPY: : 1 $MxPf:75.18 $RPf: 75.18 Pips:28.70 $DdBp:-2.55 $DdAp:0.00 GapTp:1.00
427: 05:19 USDJPY: : 1 $MxPf:75.18 $RPf: 61.13 Pips:23.70 $DdBp:-2.55 $DdAp:0.00 GapTp:4.00
428: 05:20 USDJPY: : 1 $MxPf:75.18 $RPf: 56.06 Pips:21.90 $DdBp:-2.55 $DdAp:0.00 GapTp:5.80
That would have been a good time to extract profit or trigger an exit at some threshold.
Later in the day there was a chance to breakeven:
Code: Select all
1235: 15:20 USDJPY: : 1 $MxPf:75.18 $RPf: 14.94 Pips:7.30 $DdBp:-2.55 $DdAp:-30.53 GapTp:20.40
1236: 15:21 USDJPY: : 1 $MxPf:75.18 $RPf: -0.57 Pips:1.80 $DdBp:-2.55 $DdAp:-30.53 GapTp:25.90
1237: 15:22 USDJPY: : 1 $MxPf:75.18 $RPf: -18.65 Pips:-4.60 $DdBp:-2.55 $DdAp:-30.53 GapTp:32.30
1238: 15:23 USDJPY: : 1 $MxPf:75.18 $RPf: -15.26 Pips:-3.40 $DdBp:-2.55 $DdAp:-30.53 GapTp:31.10
1239: 15:24 USDJPY: : 1 $MxPf:75.18 $RPf: -29.11 Pips:-8.30 $DdBp:-2.55 $DdAp:-30.53 GapTp:36.00
and finally after 16:30, there was no hope:
Code: Select all
1355: 16:30 USDJPY: : 1 $MxPf:75.18 $RPf: -41.56 Pips:-12.70 $DdBp:-2.55 $DdAp:-68.76 GapTp:40.40
1371: 16:36 USDJPY: : 1 $MxPf:75.18 $RPf: -49.49 Pips:-15.50 $DdBp:-2.55 $DdAp:-68.76 GapTp:43.20
1372: 16:37 USDJPY: : 1 $MxPf:75.18 $RPf: -53.17 Pips:-16.80 $DdBp:-2.55 $DdAp:-68.76 GapTp:44.50
1373: 16:38 USDJPY: : 1 $MxPf:75.18 $RPf: -55.72 Pips:-17.70 $DdBp:-2.55 $DdAp:-68.76 GapTp:45.40
1374: 16:39 USDJPY: : 1 $MxPf:75.18 $RPf: -54.59 Pips:-17.30 $DdBp:-2.55 $DdAp:-68.76 GapTp:45.00
1375: 16:40 USDJPY: : 1 $MxPf:75.18 $RPf: -72.73 Pips:-23.70 $DdBp:-2.55 $DdAp:-72.73 GapTp:51.40
1376: 16:41 USDJPY: : 1 $MxPf:75.18 $RPf: -78.97 Pips:-25.90 $DdBp:-2.55 $DdAp:-78.97 GapTp:53.60
1377: 16:42 USDJPY: : 1 $MxPf:75.18 $RPf: -70.46 Pips:-22.90 $DdBp:-2.55 $DdAp:-78.97 GapTp:50.60
1378: 16:43 USDJPY: : 1 $MxPf:75.18 $RPf: -76.98 Pips:-25.20 $DdBp:-2.55 $DdAp:-78.97 GapTp:52.90
1379: 16:44 USDJPY: : 1 $MxPf:75.18 $RPf: -69.04 Pips:-22.40 $DdBp:-2.55 $DdAp:-78.97 GapTp:50.10
1380: 16:45 USDJPY: : 1 $MxPf:75.18 $RPf: -76.13 Pips:-24.90 $DdBp:-2.55 $DdAp:-78.97 GapTp:52.60
It is only carelessness that allows a near win to drift all the way to the original stoploss and a few tweaks should prevent this from happening in future.