Hi, I modified prorealtime gapdetection indicator to a simple strategy basis for a long position.
Only 1 or 2 parameters and it gives interesting results with a simple stop of 1% for intraday or for daily a stop of 3%
the parameter has very small range i.e. 1-14 to optimise.
some stock/futures 5 min with 50.000 units backtest
p=1 unilever 81.89 % profitable with win/loss 1.8 in 497 trades.
p=1 tkh 71.67 % profitable with win/loss 1.54 473 trades
p=1 heineken 82,46% profitable with win/loss 1.48 496 trades
p=5 aex 5 min 84.44% profitable with win/loss 1.65 270 trades
Have a look and maybe it’s interesting enough to dig further !
//Strategy: GapCatcherLong
DEFPARAM CUMULATEORDERS = false
DEFPARAM PRELOADBARS = 1000
//DEFPARAM FLATBEFORE = 100000
//DEFPARAM FLATAFTER = 200000
//lasttime = 235900
//begintime = 000000
//endtime = 210000
Amplitude = 0
Detector = 0
p=5
// buy criteria
if close < dclose(p) then
if (abs((high-low[1]) / low[1]) > Amplitude) then
detector = 1
endif
endif
// sell criteria
if close > dclose(p) then
if (abs((low-high[1]) /high[1]) > Amplitude) then
detector = -1
endif
endif
// long entry
// if time >= begintime and time<=lasttime then
if not longonmarket and detector = 1 then
buy 1 lot at market
SET STOP %LOSS 1
endif
//endif
// long exit
if longonmarket and detector = -1 then
sell at market
endif
//If time >= endtime then
//if longonmarket then
//sell at market
//elsif shortonmarket then
//exitshort at market
//endif
//endif
//If dayofweek >= 5 and hour > 17 Then
//If longonmarket Then
//Sell at market
//ElsIf shortonmarket Then
//Exitshort at market
//EndIf
//EndIf
GRAPH detector coloured(300,0,0) AS "detector" //noting
GRAPH (positionperf*100) coloured(0,0,0,255) AS "PositionPerformance"
You must be logged in to post a comment.
BONJOUR PAUL impossible de tenter le trading automatique, PRT me dis que l instruction "GRAPH" ne passe pas...as tu une solution? cordialement
You're right. It's always bigger then 0 unless it's 0, which can happen the way you said.. You can set a different amplitude like 0.0005 which probably makes more sense. In the original gap detection indicator the value is also bigger then 0. With different coding on amplitude you can improve the code, although it gives more parameters to optimise.
Although it looks interesting just wondering: Aren't the second conditions for the buy and sell criteria [Buy: (abs((high-low[1]) / low[1]) > Amplitude) ; Sell: (abs((low-high[1]) /high[1]) > Amplitude)] always true due to the use of "abs" with amplitude at 0 [unless high and low[1] or high[1] and low are exactly the same]?
thanks, which underlying are you using?
merci. vous l utiliser actuellment sur quel instrument vous? et quel timeframe? Merci