Check this out – by splitting into 2 strategies for long and short then re-optimizing each individually gives an extra 60% gain with combined win rate of 97% (4 losses out of 122).
More trades, more wins, lower drawdown, better best trade, better average gain, better gain/loss.
Left hand image is the combined strategy, based on Paul’s EURCAD-DhighDlow-v1p position size =1
Hi guys,
It is true that the gains are better by optimizing each strategy, long and short. However, limited risk accounts do not allow two opposite positions to be opened simultaneously as this can happen by putting these two strategies on the market.
limited risk accounts do not allow two opposite positions
Yes, that is something to be aware of. But in that case I would be inclined to run this one long-only – almost the same return with 98% wins.
I’m on a standard account so it’s not a problem. I’ve been reviewing all my algos that run both ways and in every case they’re better off split. To me this makes total sense, as each one then has one task instead of two and is sure to be more efficient.
@Nonetheless,
Can you share your optimized .itf files ?
Thank you,
I just greyed out the relevant long / short details from each then optimized the trend and period variables. I did this over the whole 100k with no WF so you might want to look at it again, but the basic code is so good I didn’t feel that another WF was necessary. Would probably need further adjustments if looking back 200k…
My version also has money management which was off during the tests. If you want to enable it, change line 10 to MM2ndType = 1
Many thanks to Matriciel and Paul and everyone else for this excellent piece of work!
la version ITF du dernier code est elle qq part?
bertrandpinoy – English only in the English speaking forums please. 🙂
bertrandpinoy – Please stop posting in French in the English speaking forums. I have deleted your last post – please re-post in English or open a topic in the French forum if you wish to communicate in French.
Why does this strage use 2 moving averages? I have modified it use only one single MA and it works quite beautifully too.
31 wins and 4 losses over pass 10000 periods of 30 mins.
3.88 gain/loss
DEFPARAM CumulateOrders = False
DEFPARAM PRELOADBARS = 10000
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
Schedule = time >= 000000 and time <= 220000
PositionsizeA = 3
PositionsizeV = 3
MM = Average[135](totalprice)
Newhighest=max(DHigh(0), DHigh(1))
Newlowest=min(DLow(0), DLow(1))
Middle = (Newhighest+Newlowest)/2
Overbought = average[150]((Newhighest+Middle)/2)
Oversold = average[150]((Newlowest+Middle)/2)
CA = (MM > Overbought) and (close crosses over Middle)
CV = (MM < Oversold) and (close crosses under Middle)
// Long Entries
IF Schedule AND CA AND not daysForbiddenEntry AND NOT SHORTONMARKET THEN
BUY PositionsizeA CONTRACTS AT MARKET
ENDIF
IF LONGONMARKET THEN
SELL AT TRADEPRICE +50*pointsize LIMIT
ENDIF
// Short Entries
IF Schedule AND CV AND not daysForbiddenEntry AND NOT LONGONMARKET THEN
SELLSHORT PositionsizeV CONTRACTS AT MARKET
ENDIF
IF SHORTONMARKET THEN
EXITSHORT AT TRADEPRICE - 50*pointsize LIMIT
ENDIF
//MFE
//trailing stop
trailingstop = 40
//resetting variables when no trades are on market
if not onmarket then
MAXPRICE = 0
MINPRICE = close
priceexit = 0
endif
//case SHORT order
if shortonmarket then
MINPRICE = MIN(MINPRICE,close) //saving the MFE of the current trade
if tradeprice(1)-MINPRICE>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MINPRICE+trailingstop*pointsize //set the exit price at the MFE + trailing stop price level
endif
endif
//case LONG order
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close) //saving the MFE of the current trade
if MAXPRICE-tradeprice(1)>=trailingstop*pointsize then //if the MFE is higher than the trailingstop then
priceexit = MAXPRICE-trailingstop*pointsize //set the exit price at the MFE - trailing stop price level
endif
endif
//exit on trailing stop price levels
if onmarket and priceexit>0 then
EXITSHORT AT priceexit STOP
SELL AT priceexit STOP
endif
//SET TARGET pPROFIT 46
SET STOP pLOSS 100
OOS is very bad on GBPJPY @redfoxspacewolf
OOS = out of sample. You optimized for 10,000 bars but if you run it on 100,000, or even 20,000 it fails – sorry!
Do you recommend that I run a 100000 period test for it to fit better? I have executed the system and it was profitable in the last 7 trades
Do you recommend that I run a 100000 period test for it to fit better?
All you are then doing is curve fitting it to all the data available. Best practice is to develop a strategy on part of the data available (which is your in sample test) and then test it on the rest of the data available once you have finished the strategy – this is your OOS test. If the strategy is good then it should perform the same or close on the the OOS data. If it flops then it is a sure sign that you just fitted it to your IS data – so bin it and start again. Never be tempted to tweak a failed strategy so that it works on all the data as you are just curve fitting it to all your data and then have no way to check if it is curve fitted except forward testing it on future data.
Your 7 winning trades is a good forward test so far but as a data sample it is tiny and not to be trusted. Leave it running on live demo for a few years before committing any real money to it would be my suggestion.
More data gives a bigger picture, but you have to do a Walk Forward analysis to check the performance in and out of sample. There’s a chapter in the manual that’ll show you how to do that.
(Posted before i saw Vonasi’s reply)