This is not my code but I have modified it a bit.
Optimized it with a regular back test. (100%)
Then I did a WF with 5 periods with 70% IS.
The result looks pretty good according to what I learned the last few days about WF.
DEFPARAM CumulateOrders = FALSE// Posizioni cumulate disattivate
ONCE trailingStopType = 1 // 0 NONE, 1 TRAILING
ONCE percprofit = 0.5 // 0.5
ONCE percloss = 1 // 1
ONCE barlong = 15 //15
ONCE barshort = 15 //15
ONCE atrtrailingperiod = 200 //200
ONCE minstop = 5 //5 Pipsize - least distance of the stop for IG
ONCE trailingstoplong = 15 //15 Trailing stop start and distance
ONCE trailingstopshort = 15 // 15
// FRACTAL
ONCE CP = 120 // 120
// MOVING AVERAGE
ONCE avgLongPeriod = 80 // 80
// CUMMRSI
ONCE CumRsiPer = 2 // 2
ONCE cumrsiEnterLongThreshold = 160 // 160
ONCE cumrsiEnterShortThreshold = 60 // 60
// TRAILINGSTOP
//----------------------------------------------
atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pointsize)
//atrtrail = AverageTrueRange[atrtrailingperiod]((close/10)*pointsize)/1000 // for indices divided for 1000
trailingstartl = round(atrtrail*trailingstoplong) //trailing stop start and distance
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 SETTING
///BILL WILLIAM FRACTAL INDICATOR
//CP=PERIOD
if Close[cp] >= highest[2*cp+1](Close) then
LH = 1
else
LH = 0
endif
if Close[cp] <= lowest[2*cp+1](Close) then
LL = -1
else
LL = 0
endif
if LH = 1 then
HIL = Close[cp]
endif
if LL = -1 then
LOL = Close[cp]
endif
PTN01 = (close CROSSES OVER HIL)
PTN02 = (close CROSSES UNDER LOL)
// CUMRSI
CUMRSI = SUMMATION[CUMRSIPER](RSI[CUMRSIPER](close))
// ENTRY
cumrsiFilterEnterLong = (cumrsi > cumrsiEnterLongThreshold)
cumrsiFilterEnterShort = (cumrsi < cumrsiEnterShortThreshold)
//MOVING AVERAGE
longAvg = Average[avgLongPeriod] (close)
//Enter
avgFilterEnterLong = (close>longAvg)
avgFilterEnterShort = (close<longAvg)
//--------------------------------------------------------------------------------------------------
// STRATEGY
//--------------------------------------------------------------------------------------------------
if (time >=100000 and time < 230000) then
IF NOT LongOnMarket AND avgFilterEnterLong AND PTN01 AND cumrsiFilterEnterLong THEN
BUY 1 CONTRACT AT MARKET
ENDIF
IF NOT ShortOnMarket AND avgFilterEnterShort AND PTN02 AND cumrsiFilterEnterShort THEN
SELLSHORT 1 CONTRACT AT MARKET
ENDIF
ENDIF
// Condizioni per uscire da posizioni long
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 percloss
SET TARGET %PROFIT percprofit
graph tgl
graph tgs
Strange I get better looking equity curve on DAX and DJI than I do on EURUSD over 100k bars, Spread = 2 in all images attached.
My results auger well for the strategy being robust (good on 2 Markets, maybe more? )
Why are my results on eurusd not good over 100k bars (3rd image attached). If I look at half of your equity curve over 200k bars on eurusd then yours increases steadily, mine does not!
Ill go check timezones in the code and amend to match yours in Sweden.
Thanks anyway for sharing.
I have set it going on Demo DAX 1H for now.
Ill go check timezones
Yeah that was it … Times at Line 104 … knocked 1 hour off (to get same as Sweden) better equity curves on all 3 Markets now!
Nice one Stefan! 🙂
This is my time settings.
Must test DAX and DJ.
I use spread 1 on EURUSD.
knocked 1 hour off (to get same as Sweden)
I meant I set your 100000 (Sweden UTC +2) to 090000 (UTC+1 in UK)