Here,
a 200000 backtest.
it seem good, but the problem with this strategy are the slippage and spread during news or big event?
what do you think about this?
@rejo007: Looks pretty nice. Only drawdown missing, probably because of that bug when testing…
yes, i have lot of time this problem of withdraw…
ALEModerator
Master
NEW VERSION
DEFPARAM CumulateOrders = FALSE// Posizioni cumulate disattivate
ONCE trailingStopType = TRT // 0 NONE, 1 TRAILING
ONCE percprofit = TP // 0.5
ONCE percloss = SL // 1
ONCE barlong = BXL //15
ONCE barshort = BXS //15
ONCE atrtrailingperiod = ATRSP //200
ONCE minstop = MINSTP //5 Pipsize - least distance of the stop for IG
ONCE trailingstoplong = TSL //15 Trailing stop start and distance
ONCE trailingstopshort = TSS // 15
// FRACTAL
ONCE CP = CPI // 120
// MOVING AVERAGE
ONCE avgLongPeriod = AVGL // 80
// CUMMRSI
ONCE CumRsiPer = CRP // 2
ONCE cumrsiEnterLongThreshold = CREL // 160
ONCE cumrsiEnterShortThreshold = CRES // 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
ATTENTION TO THE TRAILING STOP, NEEDS TO DIVIDE THE DECIMAL, AS SUITABLE ONES TO TRY USING THE FUNCTION GRAPH
Hello ALE. It doesn’t seem to fair too well in 100K WF testing. Not many trades to base it on though. Do you get similar results?
HI Ale,
interest concept , did you test with 200k bar also ?
Thansk
ALEModerator
Master
Hello,
I’ve work since 2010 to test tick by tick, because we have had many different from real version and backtest, anyway I’ve attached my result with 1 pip spread :
Those are interesting results ALE. I guess you could call my 100k WF test an in sample test which although profitable the WF results would give reason for doubts about robustness. Then your 200k test provides an out of sample period where strategy performance is comparable. This gives some confidence that it may continue working. My only concern is the number of trades – 129 is not many. Glad to see that my Cumulative RSI idea has been kept in the strategy though!
Definitely one to watch.
ALEModerator
Master
On 1 hour time frame , It’s difficult to speake about robustness, I suggest to look for high Gain/loss value.
On 1 hour time frame , It’s difficult to speake about robustness, I suggest to look for high Gain/loss value.
That is very interesting that you say that as I have been struggling to persuade myself that my shorter time frame strategies (1Hour or less) are any good and finding that my longer (daily and 4Hr) are proving more robust after WF testing. Maybe you are right and WF testing is less relevant to shorter time frame strategies but I cannot think why that would be. Have you run a WF on your 200K period or back to 2010 period using a dummy value to see how it fairs?
Regarding WF on short time frame strategies – maybe we just need to be happy that it is profitable in every OS period tested rather than getting hung up on the actual number and looking for the perfect result?
Hello,
Could you post the files without variables, because I have problem to run it.
Thanks a lot
Usdjpy and gbpusd could be a good pair for this strategy
With the permission of ALE,
Here is the file without the graphics and the variables, so you can run it in DEMO.
btw, Very nice job of improvement of the original code.
Saludos,
Juan
ALEModerator
Master
THANK YOU VERY MUCH JUAN!… 😉
ALEModerator
Master
@Vonasi,
as we know the problem is the unpredictable movement of the market under daily time frame. The best and simple strategy that we can find are often on daily time frame. The WF work good, the problem it’s unpredictability and the and the ever-changing market movements on low time frames.