Thank you very much. Here I attach an AUD/USD optimised cross (tick by tick).
I’m from Italy too, not from Sweden.
Hi and thanks for this strategy ALE. Nice and solid foundation to keep working from and adapt to more markets etc.
Just a though regarding the minstop, correct me if wrong. I guess the variable minstop is supposed to be set in pips, but there is no pointsize multiplier in the row “if MAXPRICE–tradeprice(1)>=MINSTOP then“. Makes no difference in the indexes since pipsize is 1, but if used on currency pairs this might distort the results. I see that in the posted eurusd version of the strategy this error has not been detected, so the if condition above is never true, which makes the trailing stop consistently being set to minimum according to row “PREZZOUSCITA = MAXPRICE – MINSTOP*pointsize“.
Above comment applies to short as well as long part of the trailing stop.
Best Regards, Tedvin
ALEModerator
Master
@Alberto,
also if I’ll never use on real account the following optimization I’ve attached anothe version for AUD/USD
Thank you for your optimised AUD/USD. I’ll try to search a better version, but I think this cross is a hard one. I don’t like the declining curve at the end.
Are you running this automated strategy live with any asset?
ALEModerator
Master
Hello Alberto,
I’m busy with others but I could consider major market like Nasdaq, Dax etc. in real
Hello
I´ve been testing this code on some different fx pairs and some other markets and have gotten some amazing results. Is this code really legit? I see that many of the trades are closed within the first bar (0 bar). But tested with t-b-t this shouldn´t be a problem.
Can´t see anything that looks non legit except for the result… What do you think?
You can see some of my backtest down below. I´ve optimized on the latest 5-10 years and the rest is OOS.
Are you sure you were testing them tick by tick? In ProRealTime the tick-by-tick test starts from 2010, whereas your screenshots start previously.
I´m getting the same result in tick by tick.
Sorry for dubbel posting but here´s the code for aud/Usd for example. Optimized from 2010-07-20 to 2018-02-01 (see the line in the picture). 1988-2010 is all oss.
DEFPARAM CumulateOrders = FALSE
ONCE avgEnterEnabled = 2 //Moving Average Entry Filter - 0 OFF, 1 ON
ONCE trailingStopType = 1 // Trailing Stop - 0 OFF, 1 ON
ONCE takeprofit = 1.2 // Take Profit %
ONCE stoploss = 0.9 // Stop Loss %
ONCE trailingstoplong = 23 // Trailing Stop Atr Relative Distance
ONCE trailingstopshort = 9 // Trailing Stop Atr Relative Distance
ONCE barlong = 1 // Exit Time Long
ONCE barshort = 3 // Exit Time Short
ONCE atrtrailingperiod = 380 // Atr parameter Value
ONCE minstop = 3 // Minimum Trailing Stop Distance
// MOVING AVERAGE - Parameter
ONCE avgLongPeriod = 200 // 100
// Smoothed Bollinger %b indicator - Parameters
ONCE period = 3
ONCE TeAv = 1
ONCE SveEnterLongThreshold = 35
ONCE SveEnterShortThreshold = 65
// TRAILINGSTOP
//----------------------------------------------
atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pipsize)
trailingstartl = round(atrtrail*trailingstoplong)
trailingstartS = round(atrtrail*trailingstopshort)
if trailingStopType = 1 THEN
TGL =trailingstartl
TGS=trailingstarts
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PREZZOUSCITA = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
if MAXPRICE-tradeprice(1)>=MINSTOP then
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ELSE
PREZZOUSCITA = MAXPRICE - MINSTOP*pointsize
ENDIF
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
if tradeprice(1)-MINPRICE>=MINSTOP then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ELSE
PREZZOUSCITA = MINPRICE + MINSTOP*pointsize
ENDIF
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
ENDIF
//--------------------------------------------------------------------------------------------------
// FILTER SETTINGS
//--------------------------------------------------------------------------------------------------
//MOVING AVERAGE
longAvg = Average[avgLongPeriod] (close)
avgFilterEnterLong = (close>longAvg OR NOT avgEnterEnabled)
avgFilterEnterShort = (close<longAvg OR NOT avgEnterEnabled)
//Smoothed Bollinger %b indicator
haOpen = ((Open[1]+High[1]+Low[1]+Close[1])/4 + (Open[2]+High[2]+Low[2]+Close[2]))/2
haC = ((Open+High+Low+Close)/4 + haOpen + Max(high,haOpen) + Min(low,haOpen)) /4
TMA1 = tema[TeAv](haC)
TMA2 = tema[TeAv](TMA1)
Diff = TMA1-TMA2
ZlHA = TMA1+Diff
percb = (tema[TeAv](ZLHA)+2*STD[period](tema[TeAv](ZLHA))-weightedaverage[period](tema[TeAv](ZLHA))) / (4*STD[period](tema[TeAv](ZLHA)))*100
SveFilterEnterLong = (percb < SveEnterLongThreshold )
SveFilterEnterShort = (percb > SveEnterShortThreshold )
// STRATEGY
//--------------------------------------------------------------------------------------------------
IF NOT LongOnMarket AND avgFilterEnterLong AND SvEFilterEnterLong THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF NOT ShortOnMarket AND avgFilterEnterShort AND SveFilterEnterShort THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
IF POSITIONPERF<0 THEN
IF LongOnMarket AND BARINDEX-TRADEINDEX(1)>= barLong THEN
SELL AT MARKET
ENDIF
ENDIF
IF POSITIONPERF<0 THEN
IF shortOnMarket AND BARINDEX-TRADEINDEX(1)>= barshort THEN
EXITSHORT AT MARKET
ENDIF
ENDIF
SET STOP %LOSS stoploss
SET TARGET %PROFIT Takeprofit
///GRAPH TGL
Compliments for your optimisation. Much better than mine. I’ve tried it and I get more or less the same results.
I’m optimising other assets, but it’s a little difficult. There are a lot of variables to set in advance.
Good job guys! Nice to see you are using OOS validation for your optimized variables settings.
@ale congratulations for the strategy
Thanks Alberto and Nicolas.
The only problem I´ve noticed so far is that the code dosen´t seem to like to have a open position over the weekend. As you can see in the picture below the code is turning it self off.
Does anyone have an idea of what the problem could be?
Cheers
ALEModerator
Master
This problem is over this strategy, i’d like to know why