MikeParticipant
Junior
When I back test with 5 variables I get a profit of £130k. When I change the variables to their optimised absolute values within the code (ready to Automatic Trade) I get £18k. When I change 1 absolute value back to a variable (which I have left “sitting” in the variable optimisation section) I get £130.
Can anyone advise me what I might be doing wrong.
Thanks
Mike
MikeParticipant
Junior
This is a tick by tick mode “problem”. Even with variables set to fixed values the tick by tick mode does not activate.
I thought clicking on each line of the optimisation report was supposed to activate tick by tick mode. It seems not. Can anyone advise how to get reliable test results?
Thanks
Mike
Have you got tick by tick selected?
MikeParticipant
Junior
Yes. I realise that Optimisation does not use tick by tick, although I have ticked that option. I thought that clicking on the apparently optimal set of variables would “drill down” into a tick by tick test.
I thought that clicking on the apparently optimal set of variables would “drill down” into a tick by tick test.
You are correct.
I bet you feel like you are going mad / why does stuff like this happen to me?? 🙂 I often think the same when weird stuff happens to me!
I can’t think of anything else to offer, but I would test your code if you post it on here and then we can see if I get the same result as you?
I’ll keep thinking also.
MikeParticipant
Junior
Thanks
I’ll quadruple check my settings and then assuming I’ve not been a total twat I’ll post the code. Yes – thought I was losing it 🙂 All problems solved on Saturday and all back today! Great!
Thanks for taking the time to reply on Sunday.
Code to follow
Is the 130k read only from the Opti Table and then when you click on that line you get 18K on the equity curve?
You also get 18K when you put values in the code and then run the Backtest?
EDIT /PS
Just thought of this … Optimisation does not take account of a final Open trade, but running a Backtest and seeing the equity curve does take account of an Open Trade.
Unless you are using huge Lot Size I cannot see an Open trade losing 112K??
MikeParticipant
Junior
£130 was top of the opti list. When I click that line it shows £130 on the Detailed Report and on the Equity Curve. This is consistent for any line I select.
When I replace the variables in the code with the absolute values of the optimised test I get 18k. This is with tick by tick selected. When I de-select tick by tick witht the absolute values hard coded I get…..yep £130
This is where I concluded that it was a tick by tick problem…
Still quadruple checking the setup 🙂
MikeParticipant
Junior
In response to your PS – no, the equity curve looks great as it’s a nice steady uptrend, on the tick by tick and on the £130. Trade size is £400 – £600. Just that the tick by tick appears to get stopped out way sooner than the opt result (just based on looking at the first few trades)
MikeParticipant
Junior
This is the Hard Coded version with the variables as absolutes. Gets £18k
//DM system code
//--------------
//Parameters
DEFPARAM CumulateOrders = True
//Variables
DIThreshold1 = 26
DIThreshold2 = 7
//ATRMultiple =ATRM
//ADXLevel = ADXL
ADXDays = 11
DIDays = 4
TradeSize = 10//(Risk/(AverageTrueRange[DIDays][1]*ATRMultiple))
//Risk = 1000
//Conditions
ADXDownTurn = ADX[ADXDays][1] > DIPlus[DIDays][1] and ADX[ADXDays][1] > DIMinus[DIDays][1] and ADX[ADXDays][1] > ADX[ADXDays][2] and ADX[ADXDays][1] > ADX[ADXDays]
EnterLongonX = (DIplus[DIDays][1] crosses over DIminus[DIDays][1] and close > close[1] and DIplus[DIDays](close) > DIThreshold1)
EnterLongonCH = (DIplus[DIDays][1] > DIPlus[DIDays][2] and DIplus[DIDays][1] > DIplus[DIDays](close) and DIplus[DIDays](close) > DIThreshold2) and (ADX[ADXDays] > DIPlus[DIDays] or ADX[ADXDays] > DIMinus[DIDays])
//and ADX[ADXDays] > ADXLevel)
EnterShortonX = (DIminus[DIDays][1] crosses over DIplus[DIDays][1] and close < close[1] and DIminus[DIDays](close) > DIThreshold1)
EnterShortonCH = (DIminus[DIDays][1] > DIminus[DIDays][2]) and (DIminus[DIDays][1] > DIminus[DIDays](close) and DIminus[DIDays](close) > DIThreshold2) and (ADX[ADXDays] > DIPlus[DIDays] or ADX[ADXDays] > DIMinus[DIDays])
//and ADX[ADXDays] > ADXLevel)
//Instructions
IF EnterLongonX or EnterLongonCH then
BUY TradeSize PERPOINT AT MARKET
ENDIF
IF EnterShortonX or EnterShortonCH then
sellshort TradeSize PERPOINT AT MARKET
ENDIF
//IF EnterLongonCH then
//BUY TradeSize PERPOINT AT MARKET
//ENDIF
//IF EnterShortonCH then
//sellshort TradeSize PERPOINT AT MARKET
//ENDIF
IF ADXDownTurn or EnterShortonX THEN
SELL AT MARKET
ENDIF
IF ADXDownTurn or EnterLongonX THEN
EXITSHORT AT MARKET
ENDIF
// Stops and targets
SET STOP pTRAILING 40 // AverageTrueRange[DIDays][1]*ATRMultiple
//Alternative ADX Downturn calculations
//These replace each other for testing
//Testing on a Daily timescale over 3 years (10/16-09/19) produced a marginal gain for the simpler system
//ADXDownTurn = ADX[ADXDays][1] > DIPlus[DIDays][1] and ADX[ADXDays][1] > DIMinus[DIDays][1] and ADX[ADXDays][1] > ADX[ADXDays][2] and ADX[ADXDays][1] > ADX[ADXDays]
//ADXDownTurn = ADX[ADXDays][1] > DIPlus[DIDays][1] and ADX[ADXDays][1] > DIMinus[DIDays][1] and ADX[ADXDays][2] > ADX[ADXDays][3] and ADX[ADXDays][2] > ADX[ADXDays][4] and ADX[ADXDays][2] > ADX[ADXDays][1] and ADX[ADXDays][2] > ADX[ADXDays]
//Peaks (I cannot yet code this)
//if DIMinus[DiDays][1] > DIMinus[DiDays][2] and DIMinus[DiDays][1] > DIMinus[DiDays] then
//DMP = DIMinus[DIDays]
If you export (to an .itf file) the code with all the Opti values still set up etc and post that then I can import with all yuor settings and I can pop it on my Platform in less than 1 minute and it ensures I get all settings same as you.
MikeParticipant
Junior
Here’s the one with the variable
MikeParticipant
Junior
hard coded numbers in this one
Just that the tick by tick appears to get stopped out way sooner than the opt result (just based on looking at the first few trades)
Above sounds like it is blowing your account??
I imported your hard coded version and it is doing just that … using all 10k starting capital.
You have not said what market, timeframe etc?
Why don’t you try below …
DEFPARAM CumulateOrders = FALSE //(instead of True)
MikeParticipant
Junior
Sorry – I did not make my comment clear. My account (£10k) doesn’t get blow. I just meant that, eg Trade number 2 makes much more on Opt than it does in hard code as the tick by tick takes it out during day 1, whereas on Opti it runs for 3 days for a nice wee profit.
Dow Jones Industrial on Daily
I set “True” because I started testing this from 2014 and the DJI was trending up, so adding to my positions produced more profit. I’m now testing in choppy waters so I’ll re-run with False
Thanks
False = =£125 and £18 (False makes more sense logically in choppy market and it may be a way to simplify the manual testing that I seem to be destined to do). No pressure but I’m hoping for some magic 🙂