Confirmation of Trend using Neural Networks (by kind permission of Leo)
Forums › ProRealTime English forum › ProOrder support › Confirmation of Trend using Neural Networks (by kind permission of Leo)
- This topic has 37 replies, 8 voices, and was last updated 6 years ago by GraHal.
Tagged: data mining, machine learning, neural network
-
-
08/24/2018 at 2:45 PM #78955
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
12IF classifier=1 and close > Average[60](close) thenBuy 2 Contracts at MarketEdit / 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:
1 user thanked author for this post.
08/24/2018 at 3:01 PM #78960in 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.
1 user thanked author for this post.
08/24/2018 at 3:28 PM #78967Here’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!!! 🙂
12345678910111213141516171819202122232425262728293031323334353637383940//https://www.prorealcode.com/topic/interesting-web-pages-or-blogs///Variables:DEFPARAM CUMULATEORDERS = Falsecandlesback=5ProfitRiskRatio=2spread=1.5myATR=average[20](range)//+std[20](range)ExtraStopLoss=MyATR//ExtraStopLoss=3*spread*pipsizeclassifier=0//for long tradesFOR scan=1 to candlesback DOIF classifier[scan]=1 thenBREAKENDIFLongTradeLength=ProfitRiskRatio*(close[scan]-(low[scan]-ExtraStopLoss[scan]))IF close[scan]+LongTradeLength < high-spread*pipsize thenIF lowest[scan+1](low) > low[scan]-ExtraStopLoss[scan]+spread*pipsize thenclassifier=1//candleentry=barindex-scanBREAKENDIFENDIFNEXTIF classifier=1 and close > Average[60](close) thenBuy 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) ThenSell at MarketendifSET TARGET PPROFIT 100SET STOP PLOSS 10008/24/2018 at 3:38 PM #7897408/24/2018 at 3:43 PM #78979Almost 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??
08/24/2018 at 4:06 PM #78982GraHal, 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.
08/24/2018 at 4:29 PM #78985Can I split the topic into a new one starting from this post ?
Yes sure … no problem Nicolas.
Cheers08/24/2018 at 6:17 PM #79005I made an indicator from the code you are using to trigger the trades:
12345678910111213141516171819202122232425262728candlesback=5ProfitRiskRatio=2spread=1.5myATR=average[20](range)ExtraStopLoss=MyATRclassifier=0//for long tradesFOR scan=1 to candlesback DOIF classifier[scan]=1 thenBREAKENDIFLongTradeLength=ProfitRiskRatio*(close[scan]-(low[scan]-ExtraStopLoss[scan]))IF close[scan]+LongTradeLength < high-spread*pipsize thenIF lowest[scan+1](low) > low[scan]-ExtraStopLoss[scan]+spread*pipsize thenclassifier=1candleentry=barindex-scanBREAKENDIFENDIFNEXTIF classifier=1 and close > Average[60](close) thentrend = close[barindex-candleentry]ENDIFreturn trend08/24/2018 at 10:35 PM #7902808/26/2018 at 4:15 PM #79118Mods / 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657DEFPARAM CUMULATEORDERS = False//Variables:candlesback=1ProfitRiskRatio=2spread=1.5myATR=average[20](range)+std[20](range)ExtraStopLoss=MyATR//ExtraStopLoss=3*spread*pipsize//for long tradesclassifierlong=0FOR scanL=1 to candlesback DOIF classifierlong[scanL]=1 thenBREAKENDIFLongTradeLength=ProfitRiskRatio*(close[scanL]-(low[scanL]-ExtraStopLoss[scanL]))IF close[scanL]+LongTradeLength < high-spread*pipsize thenIF lowest[scanL+1](low) > low[scanL]-ExtraStopLoss[scanL]+spread*pipsize thenclassifierlong=1//candleentrylong=barindex-scanLBREAKENDIFENDIFNEXTIF 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 MarketENDIF//for short tradesclassifiershort=0FOR scanS=1 to candlesback DOIF classifiershort[scanS]=1 thenBREAKENDIFShortTradeLength=ProfitRiskRatio*((high[scanS]-close[scanS])+ExtraStopLoss[scanS])IF close[scanS]-ShortTradeLength > low+spread*pipsize thenIF highest[scanS+1](high) < high[scanS]+ExtraStopLoss[scanS]-spread*pipsize thenclassifiershort=1//candleentryshort=barindex-scanSBREAKENDIFENDIFNEXTIF 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 MarketENDIFSET TARGET PROFIT 140SET STOP PLOSS 340//return08/26/2018 at 5:08 PM #7912208/26/2018 at 7:02 PM #79126Leo 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!
1 user thanked author for this post.
08/26/2018 at 8:00 PM #79131Can’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.
1 user thanked author for this post.
08/26/2018 at 9:13 PM #79132I’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.
1 user thanked author for this post.
08/27/2018 at 2:56 PM #79173I 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.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on