Renko automatic trading
Forums › ProRealTime English forum › ProOrder support › Renko automatic trading
- This topic has 66 replies, 17 voices, and was last updated 4 years ago by 孫榗溢.
-
-
12/18/2020 at 7:11 PM #154337
I expect the problem is with the trail
123//trailing stop functiontrailingstart = 13 //15.7 //trailing will start @trailinstart points profittrailingstep = 2.9 //trailing step to move the "stoploss"if it starts at 13 points but adds 2.9 to the open it’s too close to the 10 minimum.
But there’s a bigger problem, see attached 6 month backtest. These 10 sec algos almost never work for any length of time.
(this is snucke’s MySystem1 – I renamed it)
1 user thanked author for this post.
12/18/2020 at 7:23 PM #154339That makes sense, I set the trailingstart = 20 now just to be sure. The results of the backtest certainly don’t look great. The average loss per losing trade is really high compared to the average gain of winning trades.
12/18/2020 at 7:50 PM #154343Here’s my result in live trading first 5 days. I agree with Nonetheless that these 10s systems are bound to fail after certain amount of days. But then as Grahal has previously mentioned, one would expect to have to re-optimise the system within a certain timeframe, as much as you would with any other system. Just that you have to re-optimise sooner, maybe after 1-2 weeks rather than every few months. My goal is to come up with a 10s system that only needs 1 parameter optimised to give good results. I need to work on the stop loss, as although this system has a high win rate it loses big when it loses.
Interestingly the backtest performed just now with the same parameters as my live code didn’t show the big loss that happened today. Does anyone know what could cause that?
Sorry, I should replace the custom indicator so that it will run without having this installed. I will work on that and re-post if I can get same results.
12/18/2020 at 7:52 PM #154346To add to my comment above, the system I’m running now seem to work well when 12:1 filter #2 is optimised. All other settings stays the same, renko box size etc. I will be experimenting with the machine learning code posted on these forums to see if it could work, but I have to say that I’m not 100% sure I know how to come up with the right values for the ML code.
12/18/2020 at 8:09 PM #154347That’s really nice to see eckaw! The re-optimization one could definitely live with. I guess the next thing would be to find out which of the parameters need to be re-optimized each week but it is really interesting that so far you only had to optimize one of the variables.
The one I’m running failed again on demo. eckaw, don’t you have minimum stop distance limits with your broker? If you do, which parameters do you tune for that limit to be respected? I tried the suggestion of nonetheless but it didn’t work.
12/18/2020 at 8:20 PM #154348Hej @DjungelJarl (Jag är också svensk!)
To be really honest I don’t know what my minimum stop distance is with IG, however I am aware that there is one. I simply ran the code as it was presented here – The stop loss is defined in the Van Tharp’s money management code at the top.
As I mentioned previously, I will replace the trend filter so that the version I post can be modified by others here, if anyone would like to collaborate on it.
12/18/2020 at 8:38 PM #154353Hej! Seems we swedes are all over the place even though you’re flying the wrong flag 🙂
That’s really odd! That it’s working for you without failure but not for me. Perhaps the stops behave slightly differently depending on if you run on live or demo. By the way, I was able to run your latest posted version without any problem, did you already replace the trend filter?
On the topic of machine learning, it’s a really exciting thought having a snippet of code simulate the algorithm itself every x days and re-optimizing. Surely someone must have done something similar before or perhaps the array limitations are what makes it difficult, although being able to index past bars with a variable (e.g. close[i]) should be enough.
12/18/2020 at 8:47 PM #154354Yes, born in Sweden but been living in London since 2004 and now I have dual nationality so I’m also British (due to the Brexit drama..)
I just went back to the code and realised this last version doesn’t have the custom indicator included, sorry for the confusion. I’m also not 100% sure if the price action filter under 60 minutes is correct. It seems to work but might need to be looked at.
My idea (hope) is that we only need to optimise “Period2” under 12:1 #2 on line 91.
I’m still puzzled to why the backtest doesn’t show the big loss that happened today. The settings are all the same.
Regarding ML, I believe @juanj is using it successfully when only optimising one parameter.
12/18/2020 at 8:52 PM #154356@eckaw Thank you for all the work!
@DjungelJarl Hey I actually meet the same issue as you do.Runs well on live but will constantly crash on demo. I have an IG account.
I believe it’s to do with the stops as you said. Sometimes, on my demo account, the (guaranteed) stops have to be at least 1% when it’s maybe 10-12 on my live account. No idea why though
1 user thanked author for this post.
12/18/2020 at 9:13 PM #154357@eckaw Ah I see! That sounds pretty practical nonetheless, best of both worlds 🙂
About the loss not showing up, I guess you’re running it in tick by tick mode? Otherwise I don’t know.
@BobOgden That’s so strange. One would want them to behave the same otherwise it takes away some of the backtesting… I don’t use guaranteed stops when I run them on demo, do you think it would interfere despite of this??12/18/2020 at 9:19 PM #154358@DjungelJarl Well I’ve tried both, with and without guaranteed stops on demo, with and without the readjustments of stoplosses and it just won’t work so no, I don’t think it’ll help
(except if for some reason unknown to me, the non-guaranteed stoplosses actually become guaranteed because… well idk… maybe the IG account does that? I’m confused tbh haha)
12/18/2020 at 11:41 PM #154368@BobOgden That’s very frustrating haha! I’ll just have to run everything live then 😉
@eckaw In what manner do you optimize “Period2”? WF, last 200k bars, etc. I’m also experimenting with your code now, trying different optimization setups. If I understood you correctly, since the two filters are working against each other, we only need to optimize one of them rather then both since we would anyway receive a similar effect optimizing both rather then only one of them?As BobOgden also said, nice work!
12/19/2020 at 12:12 AM #154369Running it on US TECH 100 while only optimizing Period2 also yields nice results for the last days albeit with a lower trade count than for wall street.
12/19/2020 at 1:08 AM #154372Another update, I tried it with the Machine Learning snippet of @juanj and leaving most of the settings at default produced slightly better results than using the latest optimized value of Period2 = 9.
The code that was inserted:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108// Heuristics Algorithm StartIf onmarket[1] = 1 and onmarket = 0 Thenoptimize = optimize + 1EnDifStartingValue = 9ResetPeriod = 1 //Specify no of months after which to reset optimizationIncrement = 1MaxIncrement = 4 //Limit of no of increments either up or downReps = 6 //Number of trades to use for analysisMaxValue = 100 //Maximum allowed valueMinValue = 1 //Minimum allowed valueonce monthinit = monthonce yearinit = yearIf (year = yearinit and month = (monthinit + ResetPeriod)) or (year = (yearinit + 1) and ((12 - monthinit) + month = ResetPeriod)) ThenValueX = StartingValueWinCountB = 0StratAvgB = 0BestA = 0BestB = 0monthinit = monthyearinit = yearEndIfonce ValueX = StartingValueonce PIncPos = 1 //Positive Increment Positiononce NIncPos = 1 //Neative Increment Positiononce Optimize = 0 ////Initialize Heuristicks Engine Counter (Must be Incremented at Position Start or Exit)once Mode = 1 //Switches between negative and positive increments//once WinCountB = 3 //Initialize Best Win Count//GRAPH WinCountB coloured (0,0,0) AS "WinCountB"//once StratAvgB = 4353 //Initialize Best Avg Strategy Profit//GRAPH StratAvgB coloured (0,0,0) AS "StratAvgB"If Optimize = Reps ThenWinCountA = 0 //Initialize current Win CountStratAvgA = 0 //Initialize current Avg Strategy ProfitFor i = 1 to Reps DoIf positionperf(i) > 0 ThenWinCountA = WinCountA + 1 //Increment Current WinCountEndIfStratAvgA = StratAvgA + (((PositionPerf(i)*countofposition[i]*100000)*-1)*-1)NextStratAvgA = StratAvgA/Reps //Calculate Current Avg Strategy Profit//Graph (PositionPerf(1)*countofposition[1]*100000)*-1 as "PosPerf1"//Graph (PositionPerf(2)*countofposition[2]*100000)*-1 as "PosPerf2"//Graph StratAvgA*-1 as "StratAvgA"//once BestA = 300//GRAPH BestA coloured (0,0,0) AS "BestA"If StratAvgA >= StratAvgB ThenStratAvgB = StratAvgA //Update Best Strategy ProfitBestA = ValueXEndIf//once BestB = 300//GRAPH BestB coloured (0,0,0) AS "BestB"If WinCountA >= WinCountB ThenWinCountB = WinCountA //Update Best Win CountBestB = ValueXEndIfIf WinCountA > WinCountB and StratAvgA > StratAvgB ThenMode = 0ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode = 1 ThenValueX = ValueX - (Increment*NIncPos)NIncPos = NIncPos + 1Mode = 2ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode = 1 ThenValueX = ValueX + (Increment*PIncPos)PIncPos = PIncPos + 1Mode = 1ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode = 2 ThenValueX = ValueX + (Increment*PIncPos)PIncPos = PIncPos + 1Mode = 1ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode = 2 ThenValueX = ValueX - (Increment*NIncPos)NIncPos = NIncPos + 1Mode = 2EndIfIf NIncPos > MaxIncrement or PIncPos > MaxIncrement ThenIf BestA = BestB ThenValueX = BestAElseIf reps >= 10 ThenWeightedScore = 10ElseWeightedScore = round((reps/100)*100)EndIfValueX = round(((BestA*(20-WeightedScore)) + (BestB*WeightedScore))/20) //Lower Reps = Less weight assigned to Win%EndIfNIncPos = 1PIncPos = 1ElsIf ValueX > MaxValue ThenValueX = MaxValueElsIf ValueX < MinValue ThenValueX = MinValueEndIFOptimize = 0EndIfgraph valuex// Heuristics Algorithm Endp2 = valueXPeriod2 is later set to p2, as this is the variable to be optimized.
See attachments for the difference in result over the last days. Unfortunately I only have access to 200k backtesting bars though.
@juanj Fantastic work with the Machine Learning!1 user thanked author for this post.
12/19/2020 at 6:08 PM #154441 -
AuthorPosts
Find exclusive trading pro-tools on