TOPIC SPLITTED FROM “Neural Networks programming” discussion: https://www.prorealcode.com/topic/neural-networks-programming-with-prorealtime/ to discuss the strategy made by GraHal about Leo’s classifier code snippet.
which function do you use for the output neurons?
how did GraHal use the code to trigger trades in this case?
I’m far from expert at coding, so I couldn’t understand your code fully, but I do like experimenting so … (rightly or wrongly?) I did below to trigger the trades! 🙂
System is doing good so far on Fwd Test … current trade at £128 profit and past trades results attached
IF classifier=1 and close > Average[60](close) then
Buy 2 Contracts at Market
Edit / PS
Bear in mind results are on 5 min TF, so maybe the good results so far are a fluke and a misuse of the code intention??
Strategy using the neural network made by Leo starts from this post:
Confirmation of Trend using Neural Networks (by kind permission of Leo)
in the Leo’s code of the “classifier”, classifier = 1 if the price has moved favorably enough to cover a risk reward ratio of 2 since a lowest low of X periods. So in your strategy you only making a bet for that movement to continue and with a simple trend filter with a SMA 60 periods.
Here’s the latest version v1.1! Rock on Leo … keep em coming!!! 🙂
Almost 4 x Profit by adding an exit filter! I had to double check to make sure I had Tick by Tick selected!!! 🙂
//https://www.prorealcode.com/topic/interesting-web-pages-or-blogs/
//Variables:
DEFPARAM CUMULATEORDERS = False
candlesback=5
ProfitRiskRatio=2
spread=1.5
myATR=average[20](range)//+std[20](range)
ExtraStopLoss=MyATR
//ExtraStopLoss=3*spread*pipsize
classifier=0
//for long trades
FOR scan=1 to candlesback DO
IF classifier[scan]=1 then
BREAK
ENDIF
LongTradeLength=ProfitRiskRatio*(close[scan]-(low[scan]-ExtraStopLoss[scan]))
IF close[scan]+LongTradeLength < high-spread*pipsize then
IF lowest[scan+1](low) > low[scan]-ExtraStopLoss[scan]+spread*pipsize then
classifier=1
//candleentry=barindex-scan
BREAK
ENDIF
ENDIF
NEXT
IF classifier=1 and close > Average[60](close) then
Buy 2 Contracts at Market
//DRAWSEGMENT(candleentry,close[barindex-candleentry],barindex,close[barindex-candleentry]+LongTradeLength) COLOURED(0,250,0)
//DRAWELLIPSE(candleentry-1,low[barindex-candleentry]-ExtraStopLoss,barindex+1,high+ExtraStopLoss) COLOURED(0,250,0)
ENDIF
//
If Close < Average[400](close) Then
Sell at Market
endif
SET TARGET PPROFIT 100
SET STOP PLOSS 100
You might want to add something to vary the spread depending on the time of day as your 1.5 is never available in the DJI.
[attachment file=78975]
Almost 4 x Profit by adding an exit filter! I had to double check to make sure I had Tick by Tick selected!!!
Above assertion of mine is wrong … it is slightly less profit than without the exit filter.
Anybody feel free to add a more effective exit??
GraHal, despite the fact that your strategy seems nice, I feel that it is now off topic and has nothing to deal with neural network anymore 🙂 Can I split the topic into a new one starting from this post ?
I’ll add backlink in each of the topic to loose no one in the process.
Can I split the topic into a new one starting from this post ?
Yes sure … no problem Nicolas.
Cheers
I made an indicator from the code you are using to trigger the trades:
candlesback=5
ProfitRiskRatio=2
spread=1.5
myATR=average[20](range)
ExtraStopLoss=MyATR
classifier=0
//for long trades
FOR scan=1 to candlesback DO
IF classifier[scan]=1 then
BREAK
ENDIF
LongTradeLength=ProfitRiskRatio*(close[scan]-(low[scan]-ExtraStopLoss[scan]))
IF close[scan]+LongTradeLength < high-spread*pipsize then
IF lowest[scan+1](low) > low[scan]-ExtraStopLoss[scan]+spread*pipsize then
classifier=1
candleentry=barindex-scan
BREAK
ENDIF
ENDIF
NEXT
IF classifier=1 and close > Average[60](close) then
trend = close[barindex-candleentry]
ENDIF
return trend
LeoParticipant
Veteran
Wow! I have no words to describe how astonish I am. I”m very glad as well that my work so far has been so useful.
Sharing is power, indeed.
Mods / Nicolas (if you agree?) please change title of this topic to …
Confirmation of Trend using Neural Networks (by kind permission of Leo)
All credit to Leo, here is version 2.0 with Shorts also!
Anybody feel free to improve and post your code on this Thread.
DJI 5 min TF, Lot size = 2, 100k bars
DEFPARAM CUMULATEORDERS = False
//Variables:
candlesback=1
ProfitRiskRatio=2
spread=1.5
myATR=average[20](range)+std[20](range)
ExtraStopLoss=MyATR
//ExtraStopLoss=3*spread*pipsize
//for long trades
classifierlong=0
FOR scanL=1 to candlesback DO
IF classifierlong[scanL]=1 then
BREAK
ENDIF
LongTradeLength=ProfitRiskRatio*(close[scanL]-(low[scanL]-ExtraStopLoss[scanL]))
IF close[scanL]+LongTradeLength < high-spread*pipsize then
IF lowest[scanL+1](low) > low[scanL]-ExtraStopLoss[scanL]+spread*pipsize then
classifierlong=1
//candleentrylong=barindex-scanL
BREAK
ENDIF
ENDIF
NEXT
IF classifierlong=1 and Close > Average[30](close)then
//DRAWSEGMENT(candleentrylong,close[barindex-candleentrylong],barindex,close[barindex-candleentrylong]+LongTradeLength) COLOURED(0,150,0)
//DRAWELLIPSE(candleentrylong-1,low[barindex-candleentrylong]-ExtraStopLoss,barindex+1,high+ExtraStopLoss) COLOURED(0,150,0)
Buy 2 Contract at Market
ENDIF
//for short trades
classifiershort=0
FOR scanS=1 to candlesback DO
IF classifiershort[scanS]=1 then
BREAK
ENDIF
ShortTradeLength=ProfitRiskRatio*((high[scanS]-close[scanS])+ExtraStopLoss[scanS])
IF close[scanS]-ShortTradeLength > low+spread*pipsize then
IF highest[scanS+1](high) < high[scanS]+ExtraStopLoss[scanS]-spread*pipsize then
classifiershort=1
//candleentryshort=barindex-scanS
BREAK
ENDIF
ENDIF
NEXT
IF classifiershort=1 and Close < Average[6](close) then
//DRAWSEGMENT(candleentryshort,close[barindex-candleentryshort],barindex,close[barindex-candleentryshort]-ShortTradeLength) COLOURED(150,0,0)
//DRAWELLIPSE(candleentryshort-1,high[barindex-candleentryshort]+ExtraStopLoss,barindex+1,low-ExtraStopLoss) COLOURED(150,0,0)
SellShort 2 Contract at Market
ENDIF
SET TARGET PROFIT 140
SET STOP PLOSS 340
//return
LeoParticipant
Veteran
Hi GraHal,
the credits is yours!
you are using a part of a neural network, far away yet to an adgorithm that learn and modify by itself.
I am glad you find a useful Spin-off
Leo is right, there’s nothing about neural network in this code 🙂 Anyway, you’ve made a great job with the short version, what about the spread used? I must say that I’m surprised with the results obtain with that simple signals!
Can’t wait until it’s a fully grown up Neural Net! 🙂
Spread = 2, yes thinking about it 4 – 6 may be be more realistic (24 hour strategy) so knock 400 – 800 or so off the profit shown above.
Mods / Nicolas (if you agree?) please change title of this topic to …
Confirmation of Trend using Neural Networks (by kind permission of Leo)
I was trying to give Leo the credit due, but also as strategies in this Topic are now Long AND Short and may <> 5 min TF.
How about … mmm, can’t think! naah leave as is! 🙂
All suggestions for Topic title and improvements to codes gratefully received.
I’m not testing this one myself at the moment but it would be interesting to see how it performs on the SP500. It is heavily correlated to the DJI but the spread is more stable through out the day. £5 minimum stake size but that is all relative to the average price movement.
[attachment file=79133]
I know it’s only early days and it could all change, but I had to post the latest results from V1.0 … hoping it may encourage readers to experiment (as I did) and share your versions of this code running on the DJI and / or other instruments.