Hi Grahal, thanks so much for the reply! Sorry I took so long to get back to you, it’s been a busy weekend!
Thanks for the code, I’ve tested it and its working well for me! I think when I was trying it before I was making it much more complicated than it needed to be!
Looking at your results, how come you are able to get 5 minute data going back 2 years? on my chart I am only able to test back one month. Also, what is the reasoning behind the close being greater than the exponential moving average?
Thanks!
Here is what I get with 200k bars and 1 point spread. Unfortunately, the stoploss is so wide that it can blow up some nice profit made by the strategy. Entries seem correct, so you should work on this stoploss part I think 🙂
Thanks Nicolas, I will update when I have sorted the correct exit.
For the short side would it be correct to write the code like this:
IF MakeTrade = 1 AND lowest[20](low) < ll THEN
fib1 = (hh - lowest[20](low)) * 0.382
Entry1 = lowest[20](low) + fib1
ENDIF
IF MakeTrade = 1 AND lowest[20](low) < ll AND close < ExponentialAverage[15](close) THEN
SELLSHORT 1 SHARES AT Entry1 LIMIT
ENDIF
This would be written alongside the buy instructions to enter if the low is broken instead of the high
Hi Kg
Is your Platform via IG and are you selecting 5Min : X Units then select 100,00 units … see attached.
Re Close > EMA is so Buys are made during an Up Period when it is more likely that following a 0.382 retracement price will then continue upwards.
Cheers
GraHal
I didn’t follow the first logic of the buy side of the strategy. Any idea GraHal? Since you have fixed it already? 🙂
I have to ‘see in my mind / vision’ what code is doing … so I get lost easily! 🙂
If I visioned it correct, the strategy is based on a 38% retracement after a rise; then continues up (Elliott Waves)? I added Close > EMA as an extra Buy condition to reduce buy trades during consolidation (Stage Analysis – 1 & 3).
SellShort needs to be the opposite logic I guess? I’ve had a play and also with 23.6% and 61.8% retracement, but I can’t get the full code to work as well as the ‘Long only code’.
My next thought / test was Line 3, is it correct KG?: Entry1 = lowest[20](low) + fib1
(I’ve been ‘lured away’ for a while by the ‘Raul Dax 5 Min Scalp’ Algo:))
Cheers
GraHal
Maybe an indicator made of the entries signals could help? That way kg6450 could easily see on charts if everything’s correct for his own strategy.
I thought that line was correct, but like you said getting it to work as well as the buy side is difficult.
There was one instance in my backtest where there was a break to the upside and it entered long, but then before the maketrade period was over there was a breakout on the bottom too. The system simply exited the long and went short which shouldnt happen.
I will have another play around with the code and post any updates!
Hi KG
Your ‘Long + my revisons’ is making money on Demo, but I’m not sure it’s working in line with Elliott Waves / Fib Retracement theory? (see attached).
Look forward to what you come up with for the Long + Short version. I’m not great at coding, but I’m enjoying helping / adding bits.
Thanks
GraHal
I made modifications myself about the code, I’m not sure about the short positions logic.. it’s may be wrong, but here is the full code.
I add a short stoploss (40 points), with a simple monthly pivots filter (above / below). Just throwing ideas on this Friday afternoon. Results are decent, even if we loose almost 2 times more than we win .. I let you review entries logic.
DEFPARAM CumulateOrders = False
DEFPARAM FlatAfter = 214500
StartTime = 065000
FinalTime = 113000
// Set Breakout box for between 5pm and 7am
If Time = 065000 THEN
hh = highest[80](high)
ll = lowest[80](low)
ENDIF
//Only make trade between 7am and 10am
MakeTrade = Time >= StartTime AND Time <= FinalTime
IF MakeTrade AND highest[20](high) > hh THEN
fib = (highest[20](high) - ll) * 0.382
Entry = ll + fib
ENDIF
IF MakeTrade AND lowest[20](low) < ll THEN
fib1 = (hh - lowest[20](low)) * 0.382
Entry1 = lowest[20](low) + fib1
ENDIF
hhh = max(high,hh)
lll = min(low,ll)
If Month<>Month[1] then
monthlyHigh = hhh[1]
monthlyLow = lll[1]
monthlyPivot = (monthlyHigh + monthlyLow + Close[1]) / 3
hh = 0
ll = close*100
Endif
IF MakeTrade AND highest[20](high) > hh AND close > monthlyPivot THEN
Buy 1 SHARE AT Entry LIMIT
ENDIF
IF MakeTrade AND lowest[20](low) < ll AND close < monthlyPivot THEN
SELLSHORT 1 SHARES AT Entry1 LIMIT
ENDIF
SET TARGET pPROFIT 100
SET STOP pLOSS 40
Nice work! Thank you Nicolas. What timezone is it please?
Regards
GraHal