Francesco78

Oil 10min "hammernegated" pattern strategy

Category: Strategies By: Francesco78 Created: July 3, 2017, 8:58 AM
July 3, 2017, 8:58 AM
Strategies
65 Comments
Oil 10min "hammernegated" pattern strategy

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]

 

Download
Filename: oil_10min_wf_results.png
Downloads: 447
Download
Filename: oil_10mins_results.png
Downloads: 674
Download
Filename: hammernegated_oil_10min.itf
Downloads: 1051
Francesco78
Francesco78 Master
Developer by day, aspiring writer by night. Still compiling my bio... Error 404: presentation not found.
Author’s Profile

Comments

juanj
9 years ago
#

What happened after August 21?

andreag76
9 years ago
#

Thank you Francesco78 !

Wilko
9 years ago
#

This was a rather interesting idea that appears to work on a short timeframe. And also interesting to know that you are running these strategies live. Will definitely take a look at this. Thanks for sharing!

Francesco78
9 years ago
#

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

rejo007
9 years ago
#

@francesco Thanks a lot, I'll take a look a this. Do you have strategy that you can share in private? If yes, we could discuss at this adress marbrerievdb@gmail.com Thanks for your reply :-)

rejo007
9 years ago
#

@francesco, i see you create a lot of strategy, thanks for your share. you test it all in live? for you what is the best? thanks a lot

Leonida1984
9 years ago
#

I am sorry but I don't speak English very well.

Leonida1984
9 years ago
#

Can I know how many trades this strategy make?

maxgomma
9 years ago
#

Good morning at all ... first of all congratulations to Francesco for the strategy and everyone for the work you do, I wanted to ask if you have solved the division problem by zero since the system still hangs ... some of you know me What do you have to do? Thank you all...

Francesco78
9 years ago
#

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.

Kv6
Kv6
9 years ago
#

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".

Francesco78
9 years ago
#

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

miguel33
9 years ago
#

tnks  George.

GraHal
9 years ago
#

Francesco thank you so much for sharing. You've been very busy lately on your very good Strategies!

Be useful to open a Forum post with same Title as this Library post then we can add and compare our results?

Cheers
GraHal 

George Michael
9 years ago
#

Of course, it’s an optimization over the Kenneth Kvistad 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   : )

George Michael
9 years ago
#

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  ;)

miguel33
9 years ago
#

George,

You can post the full code with your optimization. Thank you

mik

David Somogyi
9 years ago
#

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

 

 

Francesco78
9 years ago
#

thank you Kenneth!

Kenneth Kvistad
9 years ago
#

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

Kenneth Kvistad
9 years ago
#

 

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 :)       

 
 

manel
9 years ago
#

What Nicolas said.....:-)

larouedegann
9 years ago
#

j'ai relancé le système et effectivement il fonctionne normalement maintenant.Bizarre ?????

Il a meme pris un trade de 4 pips

Kenneth Kvistad
9 years ago
#

Hi. Did you get the problem with 0 division fixed?

manel
9 years ago
#

It's strange because I don't get that error and the system has now taken 2 trades, last one closed this morning for 4pt profit. Wonder why it only occurs for some people. 

@ Kenneth, you are right, you cannot get more than 200 candles of history with Premium account

Juan Salas
9 years ago
#

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. 

Andyswede
9 years ago
#

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

ProRealCode ProRealCode
Loading...