Forums › ProRealTime English forum › ProOrder support › Machine Learning in ProOrder ProRealTime › Reply To: Machine Learning in ProOrder ProRealTime
@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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
// Heuristics Algorithm 2 Start If onmarket[1] = 1 and onmarket = 0 Then optimize2 = optimize2 + 1 Endif StartingValue2 = 200 ResetPeriod2 = 8 //Specify no of months after which to reset optimization Increment2 = 20 MaxIncrement2 = 4 //Limit of no of increments either up or down Reps2 = 3 //Number of trades to use for analysis MaxValue2 = 270 //Maximum allowed value MinValue2 = increment //Minimum allowed value once monthinit2 = month once yearinit2 = year If (year = yearinit2 and month = (monthinit2 + ResetPeriod2)) or (year = (yearinit2 + 1) and ((12 - monthinit2) + month = ResetPeriod2)) Then ValueY = StartingValue2 WinCountB2 = 0 StratAvgB2 = 0 BestA2 = 0 BestB2 = 0 monthinit2 = month yearinit2 = year EndIf once ValueY = StartingValue2 once PIncPos2 = 1 //Positive Increment Position once NIncPos2 = 1 //Neative Increment Position once 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 Then WinCountA2 = 0 //Initialize current Win Count StratAvgA2 = 0 //Initialize current Avg Strategy Profit For i2 = 1 to Reps2 Do If positionperf(i) > 0 Then WinCountA2 = WinCountA2 + 1 //Increment Current WinCount EndIf StratAvgA2 = StratAvgA2 + (((PositionPerf(i)*countofposition[i]*100000)*-1)*-1) Next StratAvgA2 = 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 Then StratAvgB2 = StratAvgA2 //Update Best Strategy Profit BestA2 = ValueY EndIf //once BestB2 = 300 //GRAPH BestB2 coloured (0,0,0) AS "BestB2" If WinCountA2 >= WinCountB2 Then WinCountB2 = WinCountA2 //Update Best Win Count BestB2 = ValueY EndIf If WinCountA2 > WinCountB2 and StratAvgA2 > StratAvgB2 Then Mode = 0 ElsIf WinCountA2 < WinCountB2 and StratAvgA2 < StratAvgB2 and Mode2 = 1 Then ValueY = ValueY - (Increment2*NIncPos2) NIncPos2 = NIncPos2 + 1 Mode2 = 2 ElsIf WinCountA2 >= WinCountB2 or StratAvgA2 >= StratAvgB2 and Mode2 = 1 Then ValueY = ValueY + (Increment2*PIncPos2) PIncPos2 = PIncPos2 + 1 Mode = 1 ElsIf WinCountA2 < WinCountB2 and StratAvgA2 < StratAvgB2 and Mode2 = 2 Then ValueY = ValueY + (Increment2*PIncPos2) PIncPos2 = PIncPos2 + 1 Mode2 = 1 ElsIf WinCountA2 >= WinCountB2 or StratAvgA2 >= StratAvgB2 and Mode2 = 2 Then ValueY = ValueY - (Increment2*NIncPos2) NIncPos2 = NIncPos2 + 1 Mode2 = 2 EndIf If NIncPos2 > MaxIncrement2 or PIncPos2 > MaxIncrement2 Then If BestA2 = BestB2 Then ValueY = BestA Else If reps2 >= 10 Then WeightedScore2 = 10 Else WeightedScore2 = round((reps2/100)*100) EndIf ValueY = round(((BestA2*(20-WeightedScore2)) + (BestB2*WeightedScore2))/20) //Lower Reps = Less weight assigned to Win% EndIf NIncPos2 = 1 PIncPos2 = 1 ElsIf ValueY > MaxValue2 Then ValueY = MaxValue2 ElsIf ValueY < MinValue2 Then ValueY = MinValue2 EndIF Optimize2 = 0 EndIf // Heuristics Algorithm 2 End |