Well I run the back test over a longer period to make sure the profit wasnāt a fluke, and I can confirm that the code gives a 50% increase over approx 6 months. Although I think my margin requirements might be slightly wrong, and itās not stupid but I think it might be nearer 4% rather than the 2% I was planning for.
I personally still think the trend detection is too slow to react using the existing SMAs so it may be better with itās own short SMAs, so this is an obvious place to start tuning.
For anybody interest I have included a CSV which would be the trades it made in the last 6 months (only 80 odd trades.
2014-12-19 08:07:40,SELL,1.22832,2014-12-22 06:12:10,1.22546,0.00286,28.6
2014-12-22 09:55:25,SELL,1.22538,2014-12-24 08:31:20,1.21962,0.00576,57.6
2014-12-29 09:00:15,SELL,1.2181,2014-12-29 09:29:40,1.22189,-0.00379,-37.9
2014-12-29 11:00:35,SELL,1.21888,2014-12-30 07:45:00,1.21561,0.00327,32.7
2014-12-30 10:19:40,SELL,1.21521,2015-01-02 02:19:15,1.20512,0.01009,100.9
2015-01-02 07:00:10,SELL,1.20541,2015-01-04 22:00:15,1.19524,0.01017,101.7
2015-01-05 07:43:25,SELL,1.1942,2015-01-05 08:30:10,1.19726,-0.00306,-30.6
2015-01-05 09:01:25,SELL,1.19454,2015-01-05 13:15:10,1.19185,0.00269,26.9
2015-01-05 14:00:10,SELL,1.19125,2015-01-05 20:10:05,1.19451,-0.00326,-32.6
2015-01-07 07:00:00,SELL,1.18638,2015-01-07 08:01:15,1.18965,-0.00327,-32.7
2015-01-07 08:24:45,SELL,1.18752,2015-01-07 17:45:25,1.18356,0.00396,39.6
2015-01-08 08:58:45,SELL,1.17941,2015-01-08 13:58:50,1.17857,0.00084,8.4
2015-01-08 15:05:40,SELL,1.17728,2015-01-08 16:13:00,1.18032,-0.00304,-30.4
2015-01-09 07:00:00,SELL,1.17932,2015-01-09 13:25:40,1.18237,-0.00305,-30.5
2015-01-09 13:29:55,SELL,1.18113,2015-01-09 13:34:35,1.18077,0.00036,3.6
2015-01-09 15:10:45,SELL,1.1803,2015-01-09 15:33:50,1.18345,-0.00315,-31.5
2015-01-13 12:49:45,SELL,1.17809,2015-01-14 08:18:30,1.18113,-0.00304,-30.4
2015-01-14 09:28:15,SELL,1.17676,2015-01-14 10:14:30,1.17593,0.00083,8.3
2015-01-14 15:05:55,SELL,1.17723,2015-01-14 16:26:50,1.18033,-0.0031,-31
2015-01-15 08:00:35,SELL,1.17742,2015-01-15 09:34:10,1.16737,0.01005,100.5
2015-01-15 11:00:05,SELL,1.16839,2015-01-15 11:12:45,1.17156,-0.00317,-31.7
2015-01-15 12:38:00,SELL,1.17203,2015-01-15 14:49:55,1.16201,0.01002,100.2
2015-01-16 08:00:05,SELL,1.16311,2015-01-16 13:30:00,1.16144,0.00167,16.7
2015-01-16 13:31:20,SELL,1.1605,2015-01-16 15:41:35,1.15047,0.01003,100.3
2015-01-20 08:09:50,SELL,1.1578,2015-01-20 09:45:10,1.16085,-0.00305,-30.5
2015-01-21 07:07:35,SELL,1.15693,2015-01-21 13:17:50,1.15994,-0.00301,-30.1
2015-01-22 15:26:15,SELL,1.14437,2015-01-22 21:03:45,1.13429,0.01008,100.8
2015-01-23 07:27:35,SELL,1.13441,2015-01-23 09:03:30,1.12898,0.00543,54.3
2015-01-23 14:30:10,SELL,1.12117,2015-01-23 14:44:25,1.12443,-0.00326,-32.6
2015-01-26 11:27:15,SELL,1.12287,2015-01-26 13:19:10,1.12625,-0.00338,-33.8
2015-01-29 08:09:35,SELL,1.12764,2015-01-29 09:27:00,1.13064,-0.003,-30
2015-01-29 12:48:05,SELL,1.13,2015-01-29 14:00:50,1.13313,-0.00313,-31.3
2015-02-02 08:12:30,SELL,1.13066,2015-02-02 08:31:30,1.1337,-0.00304,-30.4
2015-02-10 10:04:35,SELL,1.12787,2015-02-10 12:08:55,1.13225,-0.00438,-43.8
2015-02-10 13:00:05,SELL,1.12869,2015-02-10 13:32:45,1.13182,-0.00313,-31.3
2015-02-10 15:32:30,SELL,1.12965,2015-02-10 15:41:20,1.13268,-0.00303,-30.3
2015-02-11 07:25:25,SELL,1.13079,2015-02-11 21:48:15,1.13391,-0.00312,-31.2
2015-02-12 07:01:45,SELL,1.1311,2015-02-12 08:30:00,1.13424,-0.00314,-31.4
2015-02-23 13:00:05,SELL,1.13023,2015-02-23 15:00:10,1.1335,-0.00327,-32.7
2015-02-24 07:00:00,SELL,1.13308,2015-02-24 11:28:40,1.13276,0.00032,3.2
2015-02-24 14:10:55,SELL,1.13167,2015-02-24 15:16:00,1.13505,-0.00338,-33.8
2015-02-26 13:45:05,SELL,1.12924,2015-02-26 17:40:20,1.11908,0.01016,101.6
2015-02-27 10:12:10,SELL,1.12128,2015-02-27 10:56:15,1.12431,-0.00303,-30.3
2015-02-27 11:59:10,SELL,1.12198,2015-02-27 15:08:20,1.12076,0.00122,12.2
2015-03-02 07:00:00,SELL,1.1174,2015-03-02 09:39:15,1.12047,-0.00307,-30.7
2015-03-02 13:37:45,SELL,1.12163,2015-03-03 07:04:10,1.12078,0.00085,8.5
2015-03-03 08:00:55,SELL,1.11968,2015-03-03 14:37:35,1.11864,0.00104,10.4
2015-03-04 07:00:05,SELL,1.11669,2015-03-04 15:21:15,1.10668,0.01001,100.1
2015-03-05 08:00:05,SELL,1.10516,2015-03-05 13:33:25,1.1083,-0.00314,-31.4
2015-03-05 13:52:35,SELL,1.10497,2015-03-05 14:34:45,1.10401,0.00096,9.6
2015-03-06 07:00:00,SELL,1.10144,2015-03-06 12:42:35,1.09616,0.00528,52.8
2015-03-06 13:02:10,SELL,1.09729,2015-03-06 13:33:20,1.09173,0.00556,55.6
2015-03-09 11:07:20,SELL,1.08754,2015-03-10 07:33:35,1.08166,0.00588,58.8
2015-03-10 08:03:35,SELL,1.07989,2015-03-10 09:10:30,1.07665,0.00324,32.4
2015-03-10 14:05:00,SELL,1.07518,2015-03-10 23:27:55,1.07051,0.00467,46.7
2015-03-11 07:03:35,SELL,1.06838,2015-03-11 10:12:15,1.05837,0.01001,100.1
2015-03-11 12:23:10,SELL,1.06177,2015-03-11 13:42:25,1.06063,0.00114,11.4
2015-03-11 13:48:40,SELL,1.05978,2015-03-11 15:28:40,1.05896,0.00082,8.2
2015-03-12 13:14:40,SELL,1.06142,2015-03-12 14:57:30,1.06447,-0.00305,-30.5
2015-03-13 07:00:00,SELL,1.05786,2015-03-13 07:52:55,1.06096,-0.0031,-31
2015-03-13 09:10:45,SELL,1.05984,2015-03-13 12:31:35,1.05963,0.00021,2.1
2015-03-13 13:00:05,SELL,1.05805,2015-03-13 14:32:50,1.0536,0.00445,44.5
2015-03-16 07:00:10,SELL,1.05194,2015-03-16 08:08:25,1.05509,-0.00315,-31.5
2015-03-16 10:53:45,SELL,1.05312,2015-03-16 13:07:25,1.05627,-0.00315,-31.5
2015-04-01 07:00:00,SELL,1.07605,2015-04-01 10:14:40,1.07505,0.001,10
2015-04-01 10:24:35,SELL,1.07517,2015-04-01 12:15:35,1.07817,-0.003,-30
2015-04-01 13:42:40,SELL,1.07546,2015-04-01 14:30:00,1.07862,-0.00316,-31.6
2015-04-01 14:51:25,SELL,1.07605,2015-04-02 05:45:25,1.07912,-0.00307,-30.7
2015-04-09 07:10:20,SELL,1.07708,2015-04-09 10:40:55,1.07618,0.0009,9
2015-04-09 12:44:35,SELL,1.07508,2015-04-09 17:59:55,1.06476,0.01032,103.2
2015-04-10 15:50:45,SELL,1.05955,2015-04-13 12:12:45,1.05522,0.00433,43.3
2015-04-14 08:00:05,SELL,1.05461,2015-04-14 11:01:40,1.05783,-0.00322,-32.2
2015-04-14 12:19:10,SELL,1.05595,2015-04-14 12:30:00,1.05927,-0.00332,-33.2
2015-04-15 12:05:05,SELL,1.0582,2015-04-15 12:30:15,1.06209,-0.00389,-38.9
2015-05-20 08:00:05,SELL,1.11013,2015-05-20 12:29:20,1.1138,-0.00367,-36.7
2015-05-20 13:16:40,SELL,1.11137,2015-05-20 17:47:15,1.11074,0.00063,6.3
2015-05-21 11:30:05,SELL,1.11457,2015-05-21 14:00:04,1.11378,0.00079,7.9
2015-05-21 15:00:01,SELL,1.11195,2015-05-22 04:00:46,1.11497,-0.00302,-30.2
2015-05-22 15:00:01,SELL,1.10272,2015-05-25 12:42:27,1.09901,0.00371,37.1
2015-05-26 09:56:59,SELL,1.09083,2015-05-26 12:08:01,1.09384,-0.00301,-30.1
2015-05-26 12:30:02,SELL,1.09069,2015-05-26 15:08:06,1.09037,0.00032,3.2
2015-05-27 09:38:13,SELL,1.0911,2015-05-27 13:49:40,1.08503,0.00607,60.7
2015-05-27 15:13:44,SELL,1.08652,2015-05-27 15:37:54,1.08959,-0.00307,-30.7
2015-06-01 08:38:09,SELL,1.08986,2015-06-01 11:40:03,1.09287,-0.00301,-30.1
2015-06-01 14:02:45,SELL,1.09314,2015-06-01 16:42:54,1.09182,0.00132,13.2