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
-
-
03/03/2020 at 1:43 PM #121071
@juanj Thanks a lot for sharing this!
I’am testing it live on a strategy , 1 sec, stoploss 0.1%, market orders and to make it simple I have long only.
One thing to make sure, while optimising for 200k for a few days, that it’s reset on daily basis. Did I have this (init) right?
123456789once dayinit = dayIf (day = (dayinit + ResetPeriod)) Thenboxsize = StartingValueWinCountB = 0StratAvgB = 0BestA = 0BestB = 0dayinit = dayEndIf03/03/2020 at 2:00 PM #12107203/03/2020 at 2:34 PM #121077@Paul I prefer keeping the output variable as ValueX and rather assign the target variable to ValueX (i.e. after the algorithm just set boxsize = ValueX)
Also remember ‘day ‘only goes up to 28-31 (depending on the month) and then starts again at 1 from the next month. So perhaps rather try this:
12345678910111213141516171819202122If monthinit = 1 or monthinit = 3 or monthinit = 5 or monthinit = 7 or monthinit = 8 or monthinit = 10 or monthinit = 12 ThenMonthDays = 31ElsIf monthinit = 4 or monthinit = 6 or monthinit = 9 or monthinit = 11 ThenMonthDays = 30ElsIf monthinit = 2 ThenIf (inityear/4 = round(inityear/4)) or (inityear/400 = round(inityear/400)) Then //haha not sure how exactly to do thisMonthDays = 29 //leap yearElseMonthDays = 28EndIfEndIfIf (month = monthinit and day = dayinit + ResetPeriod) or (month = monthinit + 1 and (day + (MonthDays - dayinit)) >= ResetPeriod) ThenValueX = StartingValueWinCountB = 0StratAvgB = 0BestA = 0BestB = 0dayinit = daymonthinit = monthyearinit = yearEndIf1 user thanked author for this post.
03/03/2020 at 3:30 PM #12108103/03/2020 at 3:30 PM #12108203/03/2020 at 6:33 PM #121090Depends on what you mean.
If it is the same target variable just used in different sections of the code then yes else no.
The reason being that if you apply it to 2 or more different variables the algorithm will not be able to tell which one is causing the performance increase or decrease.
I have experimented with literally duplicating the algorithm (slightly changing the name of each variable in the algorithm) and assigning it’s output to a second variable.
And although this works to some extent it definitely reduces the accuracy and efficacy of the algorithm for the same reasons mentioned above.
1 user thanked author for this post.
03/03/2020 at 9:55 PM #121101Yes I was talking about implementing machine learning on all the entry and exit variables of a system; in order to have a fully automated system that can evolve and change simultaneously with the evolution of the markets without needing human intervention.
03/04/2020 at 8:01 AM #121113You would need it to analyse every possible combination of variables as each combination of them is what has to be checked for best performance. With the arrays now in v11 this might be possible. If for example you had three variables then you could set $a[1], $b[1] and $c[1] to your first combination (10,10,10) and $a[1], $b[1] and $c[1] to your second combination (10,10,20) and so on. Then check each set for performance.
03/04/2020 at 8:18 AM #12111403/04/2020 at 8:53 AM #121116Yes – the more variables the more possibility of curve fit and it doesn’t matter if it is us or our strategy that is doing the curve fitting! That was my experience when playing with the concept anyway. Perhaps as something that just tweaks a variable value to improve strategy performance slightly the concept might work but I think that expecting it to create a strategy from a massive quantity of values and variables is a little unlikely with the computing power that we have at our finger tips.
03/04/2020 at 10:46 AM #121123I have experimented with literally duplicating the algorithm (slightly changing the name of each variable in the algorithm) and assigning it’s output to a second variable.
And although this works to some extent it definitely reduces the accuracy and efficacy of the algorithm for the same reasons mentioned above.
Did you try having algo v1 running / optimising on (for example) even number barindex and algo v2 running / optimising on odd number barindex?
Algo v1 and v2 running / optimising on different bars would prevent the algos confusing each other?
03/04/2020 at 11:31 AM #121125Hi Grahal, since the algorithm does not base it’s ‘optimization’ on time (i.e. bars) that wouldn’t make sense.
Although what could work is if you allow the two algorithms to take turns in making optimizations.
In other words each algo get x amounts of trades to analyze and make adjustments
03/04/2020 at 11:47 AM #121126allow the two algorithms to take turns in making optimizations.
Above is what I was proposing … 2 Algos in the strategy with 1 algo only optimising on each alternate bar.
Might you post the duplicate algo please with the changed variable names … I’d like to try my idea.
I did try using ValueX and ValueY, but of course there are other variables part of / common to both algos.
I am getting good results even with 1 algo … can’t believe your self-aware Opti Algo has been overlooked by us all for nearly 2.5 years!
It kinda feels like the most exciting that has happened for a long while!
Thank you so much for sharing juanj.
03/04/2020 at 11:57 AM #121127- If the algo uses the past x number of trades to optimise against … why is there a need to reset optimisation after y months?
Surely the self-optimisation is ongoing on a self improving basis?
Resetting after Y months would defeat the optimisation against recent results??
2. Does the algo increment through all prescribed values at each optimisation (against the last x trades)?
03/04/2020 at 12:21 PM #121129@GraHal to answer your questions:
- There is ‘theoretically’ no need to reset, I have merely included the option to ‘start fresh’ every quarter/year etc. in the event that optimization perhaps went wrong
- Not sure if I understand you correctly but after the evaluation period (Reps) only a single increment is made either up or down depending on which appears to improve performance more.
Here is the version of the algo outputting ‘ValueY’ (Remember the performance evaluation of each algo is only done after the amount of trades (specified as Reps) and will therefore not be useful using an alternate bar optimization method. Best is to code it so that each algo gets it’s own evaluation period. Although it would require at least 2 evaluation periods to really know if performance is increasing or decreasing. So perhaps an additional ‘wait counter’ should be built into the startegy giving each also 2 or more evaluation periods before giving the next algo a turn.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105// Heuristics Algorithm 2 StartIf onmarket[1] = 1 and onmarket = 0 Thenoptimize2 = optimize2 + 1EndifStartingValue2 = 200ResetPeriod2 = 8 //Specify no of months after which to reset optimizationIncrement2 = 20MaxIncrement2 = 4 //Limit of no of increments either up or downReps2 = 3 //Number of trades to use for analysisMaxValue2 = 270 //Maximum allowed valueMinValue2 = increment //Minimum allowed valueonce monthinit2 = monthonce yearinit2 = yearIf (year = yearinit2 and month = (monthinit2 + ResetPeriod2)) or (year = (yearinit2 + 1) and ((12 - monthinit2) + month = ResetPeriod2)) ThenValueY = StartingValue2WinCountB2 = 0StratAvgB2 = 0BestA2 = 0BestB2 = 0monthinit2 = monthyearinit2 = yearEndIfonce ValueY = StartingValue2once PIncPos2 = 1 //Positive Increment Positiononce NIncPos2 = 1 //Neative Increment Positiononce Optimize2 = 0 ////Initialize Heuristicks Engine Counter (Must be Incremented at Position Start or Exit)once Mode2 = 1 //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 Optimize2 = Reps2 ThenWinCountA2 = 0 //Initialize current Win CountStratAvgA2 = 0 //Initialize current Avg Strategy ProfitFor i2 = 1 to Reps2 DoIf positionperf(i) > 0 ThenWinCountA2 = WinCountA2 + 1 //Increment Current WinCountEndIfStratAvgA2 = StratAvgA2 + (((PositionPerf(i)*countofposition[i]*100000)*-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 ThenMode = 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 = ValueY + (Increment2*PIncPos2)PIncPos2 = PIncPos2 + 1Mode = 1ElsIf WinCountA2 < WinCountB2 and StratAvgA2 < StratAvgB2 and Mode2 = 2 ThenValueY = ValueY + (Increment2*PIncPos2)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 = BestAElseIf reps2 >= 10 ThenWeightedScore2 = 10ElseWeightedScore2 = round((reps2/100)*100)EndIfValueY = round(((BestA2*(20-WeightedScore2)) + (BestB2*WeightedScore2))/20) //Lower Reps = Less weight assigned to Win%EndIfNIncPos2 = 1PIncPos2 = 1ElsIf ValueY > MaxValue2 ThenValueY = MaxValue2ElsIf ValueY < MinValue2 ThenValueY = MinValue2EndIFOptimize2 = 0EndIf// Heuristics Algorithm 2 End -
AuthorPosts
Find exclusive trading pro-tools on