Machine Learning in ProOrder ProRealTime
Forums › ProRealTime English forum › ProOrder support › Machine Learning in ProOrder ProRealTime
- This topic has 454 replies, 32 voices, and was last updated 2 years ago by Khaled.
Tagged: machine learning
-
-
05/07/2020 at 10:58 PM #130532
Bard – Just add GRAPH TRADEON to the bottom of your strategy that has the VRT added to it. Then when you click on each optimized result you will see the ‘randomised’ bars where trades are allowed to open (tradeon = 1) and the bars where they are not allowed to open (tradeon = 0).
The VRT is simply a way of casino’ing our backtesting. It is like being at a roulette table and then regularly going to the bar and missing a few spins of the wheel and seeing how always betting on a certain number would work out if you did that – but tomorrow night your went to the bar at different times but the wheel still came up with the same numbers as the night before in exactly the same order.
1 user thanked author for this post.
09/29/2020 at 9:35 AM #145817Hi everybody,
I have a quick question about optimizations?
When the strategy bot stops for x reason, are the updates kept in memory, or does it restart from 0 when the bot is restarted?
Regards
09/29/2020 at 2:38 PM #145843Hi everybody,
I have a quick question about optimizations?
When the strategy bot stops for x reason, are the updates kept in memory, or does it restart from 0 when the bot is restarted?
Regards
They reset of course
09/29/2020 at 3:36 PM #145851I have a second strategy … suddenly, it is impossible to graph more than a week ….. Is there a way to save the optimization that the algorithm has performed for a longer period?
09/30/2020 at 11:56 AM #145949Is there a way to save the optimization that the algorithm has performed for a longer period?
You okay now? What timeframe could you not see more than 1 week of?
09/30/2020 at 5:53 PM #145992playing again with this, 2 values x & y
The code is looking back at the performance from the last xx trades. (reps)
However, if valuex is for long & valuey is for short, looking back it mixes things up with reps for long & short together and can’t be used correctly in this way I think, but i’am not sure.
09/30/2020 at 8:50 PM #146013looking back it mixes things up with reps for long & short together
You sure this isn’t due to use of the same variable name for longs and shorts?
Above tripped me up way back, only found it by running ‘both sides / halves’ separately and then I got the message … ‘this variable is not defined’ and / or ‘this variable is not used’.
10/01/2020 at 11:12 AM #146074Is there a way to save the optimization that the algorithm has performed for a longer period?
You okay now? What timeframe could you not see more than 1 week of?
The problem come from the 10 seconds timeframe….no more than 4 days
10/01/2020 at 11:44 AM #146077no more than 4 days
Yeah same for all of us … 4 days max on 10 sec TF using v10.3! 🙁
10/01/2020 at 4:26 PM #146112You sure this isn’t due to use of the same variable name for longs and shorts?
no, I don’t think so. An example would be using it for a stoploss, different for long & short.
Valuex should evaluate only the long positions & set the stoploss, valuey for the shorts, both defined by xx reps.
countofposition counts trades in similar direction.
I need to do some test on his. But it will be hard to see how the code handles past trades.Perhaps it’s best use of juanj code is focus on only long or short if using valuex/y.
1 user thanked author for this post.
10/07/2020 at 12:55 PM #146665again doing a bit of work on this code to fit my purpose.
I worked on this in the beginning, I want to have a reset daily and tried another way.
It appeared that min & max values where not respected in all times. Maybe on purpose I don’t know. I changed that I hope.
The weighting score had to be changed because of that and it was also interesting to see the difference with weighting score on or off.
Then I found, if I optimise values for 200k bars which are nice (2s timeframe), and load these values on a 100k bar, the last day results where not the same, even though they values were reset at the beginning of the day. So a few more variables had to be reset too. Now it’s close what I seek but still not perfect as there are slight differences in the last day.
this how the code looks like for now with the changes.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260// heuristics engineif heuristicsengine thenStartingValue = aaincrement = 1 //5, 20, 10maxincrement = 2 //5, 10 limit of no of increments either up orreps = 1 //1 number of trades to use for analysis //2maxvalue = 10 //20, 300, 150 //maximum allowed 12minvalue = 2 //5, minimum allowed valueStartingValue2 = bbincrement2 = 1 //5, 10maxincrement2 = 2 //1, 30 limit of no of increments either up/down //4reps2 = 1 //1, 2 nos of trades to use for analysis //3maxvalue2 = 10 //20, 300, 200 maximum allowed valueminvalue2 = 2 //5, minimum allowed valuereset = 1weighting = 0if reset=1 thenif openhour=0 thenValueX = StartingValueValuey = StartingValue2WinCountB = 0WinCountB2 = 0StratAvgB = 0StratAvgB2 = 0BestA = 0BestA2 = 0BestB = 0BestB2 = 0wincounta = 0 //initialize current win countstratavga = 0 //initialize current avg strategy profitwincounta2 = 0 //initialize current win countstratavga2 = 0 //initialize current avg strategy profitendifelseonce ValueX = StartingValueonce Valuey = StartingValue2once WinCountB = 0once WinCountB2 = 0once StratAvgB = 0once StratAvgB2 = 0once BestA = 0once BestA2 = 0once BestB = 0once BestB2 = 0endifheuristicscyclelimit = 2once heuristicscycle = 0once heuristicsalgo1 = 1once heuristicsalgo2 = 0if heuristicscycle >= heuristicscyclelimit thenif heuristicsalgo1 = 1 thenheuristicsalgo2 = 1heuristicsalgo1 = 0elsif heuristicsalgo2 = 1 thenheuristicsalgo1 = 1heuristicsalgo2 = 0endifheuristicscycle = 0elseonce valuex = startingvalueonce valuey = startingvalue2endifif heuristicsalgo1 = 1 then//heuristics algorithm 1 startif (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) thenoptimise = optimise + 1endifonce valuex = startingvalueonce pincpos = a1 //positive increment positiononce nincpos = a2 //negative increment positiononce optimise = 0 //initialize heuristicks engine counter (must be incremented at position start or exit)once mode1 = 0 //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 optimise = reps thenheuristicscycle = heuristicscycle + 1for i = 1 to reps doif positionperf(i) > 0 thenwincounta = wincounta + 1 //increment current wincountendifstratavga = stratavga + (((positionperf(i)*countofposition[i]*close)*-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 thenmode1 = 0elsif wincounta < wincountb and stratavga < stratavgb and mode1 = 1 thenvaluex = valuex - (increment*nincpos)nincpos = nincpos + 1mode1 = 2elsif wincounta >= wincountb or stratavga >= stratavgb and mode1 = 1 thenvaluex = min((valuex + (increment*pincpos)),maxvalue)pincpos = pincpos + 1mode1 = 1elsif wincounta < wincountb and stratavga < stratavgb and mode1 = 2 thenvaluex = min((valuex + (increment*pincpos)),maxvalue)pincpos = pincpos + 1mode1 = 1elsif wincounta >= wincountb or stratavga >= stratavgb and mode1 = 2 thenvaluex = valuex - (increment*nincpos)nincpos = nincpos + 1mode1 = 2endifif nincpos > maxincrement or pincpos > maxincrement thenif besta = bestb thenvaluex = bestaElseif weighting=1 thenIf reps >= 10 ThenWeightedScore = 10ElseWeightedScore = round((reps/100)*100)EndIfValueX1 = min(round(((BestA*(20-WeightedScore)) + (BestB*WeightedScore))/20),maxvalue) //Lower Reps = Less weight assigned to Win%valuex=max(minvalue,valuex1)EndIfendifnincpos = 1pincpos = 1elsif valuex > maxvalue thenvaluex = maxvalueelsif valuex < minvalue thenvaluex = minvalueendifoptimise = 0endif// heuristics algorithm 1 endelsif heuristicsalgo2 = 1 then// heuristics algorithm 2 startif (onmarket[1] = 1 and onmarket = 0) or (longonmarket[1] = 1 and longonmarket and countoflongshares < countoflongshares[1]) or (longonmarket[1] = 1 and longonmarket and countoflongshares > countoflongshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares < countofshortshares[1]) or (shortonmarket[1] = 1 and shortonmarket and countofshortshares > countofshortshares[1]) or (longonmarket[1] and shortonmarket) or (shortonmarket[1] and longonmarket) thenoptimise2 = optimise2 + 1endifonce valuey = startingvalue2once pincpos2 = a3 //positive increment positiononce nincpos2 = a4 //negative increment positiononce optimise2 = 0 //initialize heuristicks engine counter (must be incremented at position start or exit)once mode2 = 0 //switches between negative and positive increments//once wincountb2 = 3 //initialize best win count//graph wincountb2 coloured (0,0,0) as "wincountb2"//once stratavgb2 = 4353 //initialize best avg strategy profit//graph stratavgb2 coloured (0,0,0) as "stratavgb2"if optimise2 = reps2 thenheuristicscycle = heuristicscycle + 1for i2 = 1 to reps2 doif positionperf(i2) > 0 thenwincounta2 = wincounta2 + 1 //increment current wincountendifstratavga2 = stratavga2 + (((positionperf(i2)*countofposition[i2]*close)*-1)*-1)nextstratavga2 = stratavga2/reps2 //calculate current avg strategy profit//graph (positionperf(1)*countofposition[1]*100000)*-1 as "posperf1-2"//graph (positionperf(2)*countofposition[2]*100000)*-1 as "posperf2-2"//graph stratavga2*-1 as "stratavga2"//once besta2 = 300//graph besta2 coloured (0,0,0) as "besta2"if stratavga2 >= stratavgb2 thenstratavgb2 = stratavga2 //update best strategy profitbesta2 = valueyendif//once bestb2 = 300//graph bestb2 coloured (0,0,0) as "bestb2"if wincounta2 >= wincountb2 thenwincountb2 = wincounta2 //update best win countbestb2 = valueyendifif wincounta2 > wincountb2 and stratavga2 > stratavgb2 thenmode2 = 0elsif wincounta2 < wincountb2 and stratavga2 < stratavgb2 and mode2 = 1 thenvaluey = valuey - (increment2*nincpos2)nincpos2 = nincpos2 + 1mode2 = 2elsif wincounta2 >= wincountb2 or stratavga2 >= stratavgb2 and mode2 = 1 thenvaluey = min((valuey + (increment2*pincpos2)),maxvalue2)pincpos2 = pincpos2 + 1mode2 = 1elsif wincounta2 < wincountb2 and stratavga2 < stratavgb2 and mode2 = 2 thenvaluey = min((valuey + (increment2*pincpos2)),maxvalue2)pincpos2 = pincpos2 + 1mode2 = 1elsif wincounta2 >= wincountb2 or stratavga2 >= stratavgb2 and mode2 = 2 thenvaluey = valuey - (increment2*nincpos2)nincpos2 = nincpos2 + 1mode2 = 2endifif nincpos2 > maxincrement2 or pincpos2 > maxincrement2 thenif besta2 = bestb2 thenvaluey = besta2Elseif weighting=1 thenIf reps2 >= 10 ThenWeightedScore2 = 10ElseWeightedScore2 = round((reps2/100)*100)EndIfValueY1 = min(round(((BestA2*(20-WeightedScore2)) + (BestB2*WeightedScore2))/20),maxvalue2)valuey=max(minvalue2,valuey1)//Lower Reps = Less weight assigned to Win%EndIfendifnincpos2 = 1pincpos2 = 1elsif valuey > maxvalue2 thenvaluey = maxvalue2elsif valuey < minvalue2 thenvaluey = minvalue2endifoptimise2 = 0endifendif// heuristics algorithm 2 endn=valuexmultiple=valueyelsen=valuenmultiple=valuemendif10/07/2020 at 1:57 PM #14667110/07/2020 at 4:25 PM #146676How many variables can we consider working with …
Personally, I work with a strategy on which I can adjust up to 7 variables …
10/07/2020 at 4:30 PM #146677yes indeed. A reset should fix that I hoped. The code above is still not good though, now I test a strategy with lots of trades.
So a reset every day and the last full day(s) should be similar either with 50k or 200k.
Maybe the problem is even at hour 0, it looks at the performance of the last trade(s) of previous day based on reps which influences every new trade?
Here’s a pic to show the difference of the same code and the test code
10/07/2020 at 8:22 PM #146698the results are not even close to the same as when the first test occurred
If we backtest on for example 100k bars of 10 min TF then test on 100k bars of 1 hour TF then switch back to 10 mins the start date will often not be the same as the 1st 100k bars of 10 min TF.
In order to achieve the same start date on subsequent 100k bars of 10 min TF we would have to close the strategy backtesting window and start again.
Start date can be seen by hovering over the far left hand side of the chart and reading off the date bar.
It’s a while since I checked this out, so have a go and let us know please?
-
AuthorPosts
Find exclusive trading pro-tools on