Dear all,
I found this nice strategy by playing with candlestickpatterns with 2 candles.
Basically I considered the “hammer negated” pattern, where you have first an hammer candle (body on the upper or lower 25% of the candle) and then a candle which negate the hammer so in case we have a bullish hammer, then we have a candle whose body is within yesterday candle shadow. I hope it is clear as I have no idea how to draw candles on the laptop.
I added then a few moving average that identifies momentum, and opted for trailing stops.
The only thing I have optimized here are trailing stops level. All the moving average period, the parameter that defines the candlestick pattern are not optimized, no target profit either. Thats why WF results are pretty impressive.
Only downside as usual is that I dont have more than 100K history.
Enjoy
Francesco
defparam cumulateorders = false
av1 = average[5](close)
av2 = average[10](close)
av3 = average[50](close)
x = 0.5
bull = close> av1 and close >av2 and close > av3
bear = close <av1 and close <av2 and close <av3
//n= 1
hammerup = min(open[1],close[1])>high[1]-(high[1]-low[1])/3 //and timeok
hammerupnegated= max(open,close)<min(open[1],close[1]) and abs(open-close)/(high-low)>x
cs = hammerup and hammerupnegated and bear
hammerdown = max(open[1],close[1])<low[1]+(high[1]-low[1])/3 //and timeok
hammerdownnegated = min(open,close)>max(open[1],close[1]) and abs(open-close)/(high-low)>x
cl = hammerdown and hammerdownnegated and bull
if cs then
sellshort 1 contract at market
endif
if cl then
buy 1 contract at market
endif
//TRAILING STOP
TGL =18
TGS= 24
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
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
//set target pprofit n*averagetruerange[14]
//set stop ploss m*averagetruerange[14]
You must be logged in to post a comment.
Hi rejo007, thank you, yes I have all of them live and manymore that I dont share. one of my favourite is the ncandle and reversion for usdjpy. Regards
I am sorry but I don't speak English very well.
Can I know how many trades this strategy make?
hi Maxgomma and thank youm pls have a look to the forum https://www.prorealcode.com/topic/oil-10min-hammernegated-pattern-strategy/page/3/ the problem of division by zero is tackled and solved there.
Hola Francesco, Muy buenos resultados. No obstante, cuando pongo el código a funcionar, al cabo de un tiempo me aparece el siguiente mensaje: "El sistema de trading se interrumpió, porque ocurrió una división por cero durante la evaluación de la última vela. Le sugerimos que intente añadir protecciones a su código para evitar divisiones por cero, luego backtestear el sistema modificado para comprobar la corrección".
I have opened a forum thread as suggested by Grahal in order to make discussion more confortable.
https://www.prorealcode.com/topic/oil-10min-hammernegated-pattern-strategy/
Thanks
Of course, it’s an optimization over the optimization :
//CRUDO EE.UU. MINI 1€ (TF-10Min)
//BACKTEST (11/1/16 - 7/7/17) SPREAD 2.8 IG MARKETS
//CAPITAL INICIAL 1000 - 2 CONTRATOS - MAX.DD. 622€ 2 Consecutivas
defparam cumulateorders = false
av1 = average[3](close)
av2 = average[20](close)
av3 = average[49](close)
x = 0.5
bull = close> av1 and close >av2 and close > av3
bear = close <av1 and close <av2 and close <av3
hammerup = min(open[1],close[1])>high[1]-(high[1]-low[1])/3 //and timeok
hammerupnegated= max(open,close)<min(open[1],close[1]) and abs(open-close)/(high-low)>x
cs = hammerup and hammerupnegated and bear
hammerdown = max(open[1],close[1])<low[1]+(high[1]-low[1])/3 //and timeok
hammerdownnegated = min(open,close)>max(open[1],close[1]) and abs(open-close)/(high-low)>x
cl = hammerdown and hammerdownnegated and bull
if cs then
sellshort 2 contract at market
endif
if cl then
buy 2 contract at market
endif
//<a href="https://www.prorealcode.com/blog/learning/kinds-trailing-stop-proorder/" target="_blank">TRAILING STOP</a>
TGL = 29
TGS = 20
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
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
set target pprofit 52
set stop ploss 192
I’m novel in ProRealCode and i’m not sure that my optimization es better, someone with more experiencie could value that optimization… Best regards : )
Hello everyone,
For those who negotiate Crude EE.UU. 1€ in IG Markets I suggest another optimization, feel free to try it:
//BACKTEST (11/1/16 - 7/7/17) SPREAD 2.8 IG MARKETS
av3 = average[49](close)
TGL = 29
TGS = 20
set target pprofit 52//n*averagetruerange[14]
set stop ploss 192//m*averagetruerange[14]
Very good code THANK YOU Francesco78 ;)
I agree with @Kenneth, did the same optmization with TGL and TGS 30 and 20 respectively and 2 contracts for long and short positions.
Stop ploss 100
thank you Kenneth!
defparam cumulateorders = false
av1 = average[3](close)
av2 = average[20](close)
av3 = average[50](close)
x = 0.5
bull = close> av1 and close >av2 and close > av3
bear = close <av1 and close <av2 and close <av3
//n= 1
hammerup = min(open[1],close[1])>high[1]-(high[1]-low[1])/3 //and timeok
hammerupnegated= max(open,close)<min(open[1],close[1]) and abs(open-close)/(high-low)>x
cs = hammerup and hammerupnegated and bear
hammerdown = max(open[1],close[1])<low[1]+(high[1]-low[1])/3 //and timeok
hammerdownnegated = min(open,close)>max(open[1],close[1]) and abs(open-close)/(high-low)>x
cl = hammerdown and hammerdownnegated and bull
if cs then
sellshort 2 contract at market
endif
if cl then
buy 2 contract at market
endif
//TRAILING STOP
TGL =30//32
TGS= 20//32
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
PREZZOUSCITA = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PREZZOUSCITA = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PREZZOUSCITA>0 then
EXITSHORT AT PREZZOUSCITA STOP
SELL AT PREZZOUSCITA STOP
ENDIF
SET STOP ploss 110////120//120
SET TARGET pPROFIT 52//50
Hi everyone: here is diffrences between original code from Francesco78 and the one I have put stop code on and target + optimised.
Could not upload pic sorry. (dont have accsess)
US crude E1 mini 10min chart 100 000tick .
Win:87%
Gain:Alittle better than original and dosent drop 500pip but stop at 110pip.
I dont know how the optimised one will work on live trading but I guess someone with the original one can come with feedback if someone have tested it and I will test the optimised one as soon as I have enough capital too do so/ or someone else can get the code and try :)
j'ai relancé le système et effectivement il fonctionne normalement maintenant.Bizarre ?????
Il a meme pris un trade de 4 pips
Hi. Did you get the problem with 0 division fixed?
Hi,
I got the same problem in Oil USA 10'. The system was canceled because there is a division by 0. I will try to apply the modification and see what happens.
Thanks,
Juan
P.S.- By the way Francesco, thanks so much for your codes. You are doing a fantastic job.
I think i solved the division-trouble by this:(open-close)/((high-low)*1)>x
hammerupnegated= max(open,close)<min(open[1],close[1]) and abs(open-close)/((high-low)*1)>x cs = hammerup and hammerupnegated and bear hammerdown = max(open[1],close[1])<low[1]+(high[1]-low[1])/3 //and timeok hammerdownnegated = min(open,close)>max(open[1],close[1]) and abs(open-close)/((high-low)*1)>x
larouedegann
It happens to me like "Larouedegann", somewhere in the code there is an error because I am operating in real and the system stops, it says that it can not follow because there is a division by 0
What happened after August 21?