Hello everyone, as suggested by Grahal I’m opening a forum thread dedicated to my last posted strategy on oil.
http://www.prorealcode.com/prorealtime-trading-strategies/oil-10min-hammernegated-pattern-strategy/
Happy to compare results but most of all to hear your criticism in order to be able to improve in the spirit of this forum.
Best
Francesco
Hello,
I was thinking about the division by zero problem running this strategy. I would guess the (high-low) statement below would be the source of the error?
This was suggested as a correction:
hammerupnegated= max(open,close)<min(open[1],close[1]) and abs(open-close)/((high-low)*1)>x
But zero times 1 is still zero i would guess?? An IF-test would fix this, but I was wondering if there was another permanent fix?
I would suggest using
If (high-low) = 0 Then
HiLo = 1
Else
HiLo = (high-low)
EndIf
hammerupnegated= max(open,close)<min(open[1],close[1]) and (abs(open-close)/HiLo)>0.5
I was testing the strategy but also got the Zero Division last night so I have started it again with the fix from Andyswede:
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
And hope it works fine.(have to wait some days since it doesent buy to offen.
—————————————————————————————
I have also tested on the backtest with this addition:
NbrContracts = 2 //need a value for the first trade
IF PositionPerf(1) < 0 THEN
NbrContracts = 2
ENDIF
IF PositionPerf(1) > 0 and PositionPerf(2) > 0 THEN
NbrContracts = 3
Buy 3 after second win and buy 2 after first loss.
I also tested it with some sort of martin gale strategy for fun.
IF Barindex = ExitIndex + 1 THEN
ExitIndex = 0
IF PositionPerf(1) < 0 THEN
OrderSize = MAX(OrderSize -0.5, 1)
ELSIF PositionPerf(1) >= 0 THEN
OrderSize = OrderSize +0.2
ENDIF
endif
Hi Kenneth, it didn´t work, just a little bit longer 🙂 And as Ronny said, it´s still divided by zero, my wrong. I`m trying Juanj:s fix.
Thanks for your fix Juanj and of course Francesco for really nice strategy 🙂
Andy
Is this the same as you are trying Andyswede?
If (high-low) = 0 Then
HiLo = 1
Else
HiLo = (high-low)
EndIf
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)/HiLo)>0.5
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)/HiLo)>0.5
cl = hammerdown and hammerdownnegated and bull
Yes Kenneth, that´s the one, my fix stopped this morning
So this last update from Juanj might work ?
Anyway we cant give up now. Fransisco78`s strategy seems Very good:) Thanx again.
To me this morning did not do any operation
Francesco puoi darmi un tuo indirizzo mail , ho bisogno di chiederti una cosa… se vuoi ovviamente. Grazie.
EDIT: NO EMAIL PLEASE
PLEASE SPEAK ENGLISH IN ENGLISH FORUM!
hi guys, thank you for the work you are doing, I did not have this division by zero problem, but maybe you could just try to modify the formula like this
max(open,close)<min(open[1],close[1]) and abs(open–close)/((high–low+0.0000001))>x?
Doesnt change the idea underlying idea and should work as a trick?
Best
Thats great.I will test this:)
Kenneth or Francesco ,
You can describe the conditions, i want to try to im metatrader and see the differences.
Thank you for your contribution.
mik
//TRAILING STOP
TGL =18
TGS= 24
if not onmarket then
MAXPRICE = 0
MINPRICE = close
PRICEEXIT = 0
ENDIF
if longonmarket then
MAXPRICE = MAX(MAXPRICE,close)
if MAXPRICE-tradeprice(1)>=TGL*pointsize then
PRICEEXIT = MAXPRICE-TGL*pointsize
ENDIF
ENDIF
if shortonmarket then
MINPRICE = MIN(MINPRICE,close)
if tradeprice(1)-MINPRICE>=TGS*pointsize then
PRICEEXIT = MINPRICE+TGS*pointsize
ENDIF
ENDIF
if onmarket and PRICEEXIT>0 then
EXITSHORT AT PRICEEXIT STOP
SELL AT PRICEEXIT STOP
ENDIF
Hi
Being new to coding, Am I correct in thinking that there is no stop if the price moves immediately against any new trade position? (either long or short).
Also i’d be interested in hear how you decided on TGL = 18 and TGS = 24 ?
Many thanks
MIGUEL33 what you are asking for is a question for francesco78.
Carras: if price goes directly againt target after taken there is no stop loss. Tgl and tgs is only active is price moves xx pips in righ direction. Then the stop will move accordingly to price. Lets say price goes 50pips, then stoploss will be 18 or 24 pips behind/under.
Why 18 and 24 is something francesco78 have coded after his toughts. I use 30 and 20 or so. Slight diffrens.
If you whant/should after my opinion i use own code for stop loss just incase it goes directly in wrong direction, I use this code as my last rung/line in the code.
Set stop ploss xx (I use 110pip)