Machine Learning in ProOrder ProRealTime

Viewing 15 posts - 286 through 300 (of 455 total)
  • Author
    Posts
  • #128113 quote
    nonetheless
    Participant
    Master

    When I, (if I), get the Robustness Tester to be able to switch on an off

    Just a suggestion … I’ve never bothered with the on/off. I do the optimisation, add the vrt code, do the test, then strip it out again and forget about it – no longer needed. Personally, I don’t like having stuff cluttering up the code for no purpose, just in case it throws up some unintended side effect.

    #128123 quote
    GraHal
    Participant
    Master

    For example having used the larger Trailing Stop at 200 to max 300 and had no trouble backtesting Dow Daily 2015 to present, when I went back the smaller previous ranges (10 to 150 for both the Stop and the BoxSize) I immediately got a tbt warning.

    It’s due to below …

     

    So if – due  to settings / values for TP and SL – there are more than 2,500 instances of TP and SL being hit in the same bar then we get the warning message that tbt has reached it’s limit.

    #128172 quote
    Bard
    Participant
    Master

    Hi Paul, cheers, not sure why I added them, probably something wasn’t working, it was during a process of trying different things, like your new rules, without While and Wend. They were originally derived from the DocTrading rules from his Pure Renko strategy. Not being a coder I wasn’t sure that the Buy / Sell Stop would be activated unless the condition had been stated first. Good tip for the tbt issues, thanks.

    Yes that might be a good idea because Renko ML2 didn’t perform as well as I expected, not like Ehlers Universal Oscillator ML2 that I’ve posted on this thread and which had ValueX for the Longs and ValueY for the Shorts, nor the Renko ML1 ValueX Trailing Stop. So many combinations and new discoveries to be uncovered… 😀
    #128177 quote
    Paul
    Participant
    Master
    @Bard Hi, Nice job btw on the ML engine! I’ve started work on it with trying various combinations. Setup is a.t.m. focused on opening a trade in the lower spread timezone. I included the reentry when in loss on a new same signal to create more trades. Going nowhere a.t.m. regardless timeframe but anyway have a look 🙂   edit parameter MaxIncrement2 is wrongly setup. edit2; removing the once or the complete line
    renkoMaxL = ROUND(close / boxSizeL) * boxSizeL
    renkoMinL = renkoMaxL - boxSizeL
    
    renkoMaxS = ROUND(close / boxSizeS) * boxSizeS
    renkoMinS = renkoMaxS - boxSizeS
    and still does calculations?
    Renko-1M-ML2-CycLimRes-2.itf
    #128180 quote
    Bard
    Participant
    Master
    Thanks Nonetheless,
     I don’t like having stuff cluttering up the code for no purpose, just in case it throws up some unintended side effect.
    Like 5 x the profits, which is what happened when I thought it was turned off but wasn’t. Would be nice to get Vonasi’s additional on/off switch code working or otherwise I’ll probably end up settling for  VRT and non VRT versions to save time from having to delete VRT and re-add his code to just one system.
    #128182 quote
    Bard
    Participant
    Master
    due  to settings / values for TP and SL – there are more than 2,500 instances of TP and SL being hit in the same bar then we get the warning message that tbt has reached it’s limit.
    Do you think that it’s possible that there are 2,500 instances of the (ML1, ValueX) Stop Loss being triggered in the same daily candle?  Btw TP in all “my” systems TP have always been set at 500, just thought.. that in itself could do with an ML code… Where does it end? 😬 Lol.
    #128189 quote
    GraHal
    Participant
    Master
    Do you think that it’s possible that there are 2,500 instances of the (ML1, ValueX) Stop Loss being triggered in the same daily candle?
    Only if ML1 and ValueX are variables for TP and SL as that is all the tbt is concerned with. PS Btw if you select text and then click the ‘Quote’ button then the person who you are Quotng will show up in blue (as above) as a link … then if anybody wants to go back to the post all they have to do is click on the blue link. Luckily (in your post above) I remembered my own comments else I would not know who you are talking to! 🙂 🙂
    #128191 quote
    GraHal
    Participant
    Master
    Would be nice to get Vonasi’s additional on/off switch code working
    Are you following @Vonasi 2 x instructions below?? Maybe you are getting problems because you are following just one of the 2 x instructions?? Just an idea anyway, as you seem to have tried everything. Also your strategy code may be using a variable in Vonasi VRT code and that is why you get 5 x profits with the VRT code but not without??   You need to click on the blue Vonasi below and read his original post as the code (which I tried to copy for you) has come out garbled and I have to go now, sorry. Alternatively add something like this to your code and then you can simply turn the robustness tester on and off via one variable at the top of the code without the need to search through the code to find the right line to add or remove // from. 1 2 3 4 5 6 7 8 9 RobustnessTest = 0   (robustness test code here)   if not RobustnessTest then tradeon = 1 endif   (strategy code here)
    #128193 quote
    Paul
    Participant
    Master
    Should your heuristic code work on strategies that switch position from Long to Short with no bars not onmarket ? Yip that is the problem. Solution; Replace this: With This:
    #128194 quote
    Paul
    Participant
    Master
    important piece above.. Thanks to GraHal for spotting that back then! I have valuey at 0 at the beginning for a couple of trades which is not good.
    GraHal thanked this post
    #128195 quote
    Paul
    Participant
    Master
    this seems a fix  
    HeuristicsCycleLimit = 2
    
    once HeuristicsCycle = 0
    once HeuristicsAlgo1 = 1
    once HeuristicsAlgo2 = 0
    
    If HeuristicsCycle >= HeuristicsCycleLimit Then
    If HeuristicsAlgo1 = 1 Then
    HeuristicsAlgo2 = 1
    HeuristicsAlgo1 = 0
    ElsIf HeuristicsAlgo2 = 1 Then
    HeuristicsAlgo1 = 1
    HeuristicsAlgo2 = 0
    EndIf
    HeuristicsCycle = 0
    else
    StartingValue = 40
    StartingValue2= 30
    once ValueX = StartingValue
    once ValueY = StartingValue2
    EndIf
    and change below
    //StartingValue = 40 //100, 10 Boxsize
    Increment     = 5 //20, 10
    MaxIncrement  = 15 //10 Limit of no of increments either up or down
    Reps          = 3 //Number of trades to use for analysis //2
    MaxValue      = 40 //300, 150 //Maximum allowed value
    MinValue      = 15 //Minimum allowed value
    
     
    //once valueX  = StartingValue
    same valuey
    #128196 quote
    Bard
    Participant
    Master
    <p class=”p1″><span class=”s1″>Cheers, I couldn’t have done it without GraHal’s tip to use a text comparison website (to compare Juanj’s code with my often non working “exact copy” code that turned out more often than not, not to be so exact or a copy). </span></p> Short and Long Boxsizes: That would certainly make logical sense, have larger range boxes for strong uptrends to capture larger chunks of profit and then a smaller shorter range box for the minor corrections. Be interesting to test. I figured out why 1M ML2 CycLimRes v2 didn’t trade, and excuse the brutal editing of your sophisticated code, but I just had to go back step by set to first principles to see what was stopping it from trading. First cut was the stop loss – made no difference, as still no trades. Then I took out the “flat before,” still no difference, but when I took out “ctime” it took trades but not profitably and also GraphY was flat whereas Value X was being optimised. More alterations to the settings fixed it and although it’s still taking plenty of trades despite going back to some similar settings, it’s not that profitable. Putting back the stop loss code cut the nos of trades from 233 to just 14. As I said it’d be really interesting to test it more to see if the Long/Short boxsize logic works. Altering setting definitely caused some tbt warnings. Some instruments even this attached version would not trade on like Wheat or Gold.
    Paul thanked this post
    Renko-1M-ML2-CycLimRes-v2.itf Dow-R-ML2-v2.png Dow-R-ML2-v2.png £-R-ML2-v2.png £-R-ML2-v2.png
    #128201 quote
    Paul
    Participant
    Master
    you have the same problem with valuey Bard, you could try this layout with both fixes
    //Settings 1 & 2
    StartingValue = 40 //100, 10 Boxsize
    Increment     = 5 //20, 10
    MaxIncrement  = 15 //10 Limit of no of increments either up or down
    Reps          = 3 //Number of trades to use for analysis //2
    MaxValue      = 40 //300, 150 //Maximum allowed value
    MinValue      = 15 //Minimum allowed value
    
    StartingValue2= 30 //100, 50 Stop Loss
    Increment2    = 5 //5, 10
    MaxIncrement2 = 15 //30 Limit of no of increments either up/down //4
    Reps2         = 3 //2 Nos of trades to use for analysis //3
    MaxValue2     = 30 //300, 200 Maximum allowed value
    MinValue2     = 15 //Minimum allowed value
    
    HeuristicsCycleLimit = 2
    
    once HeuristicsCycle = 0
    once HeuristicsAlgo1 = 1
    once HeuristicsAlgo2 = 0
    
    If HeuristicsCycle >= HeuristicsCycleLimit Then
    If HeuristicsAlgo1 = 1 Then
    HeuristicsAlgo2 = 1
    HeuristicsAlgo1 = 0
    ElsIf HeuristicsAlgo2 = 1 Then
    HeuristicsAlgo1 = 1
    HeuristicsAlgo2 = 0
    EndIf
    HeuristicsCycle = 0
    else
    once ValueX = StartingValue
    once ValueY = StartingValue2
    EndIf
    
    If HeuristicsAlgo1 = 1 Then
    
    //Heuristics Algorithm 1 Start
     
    If (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) Then
    optimise = optimise + 1
    EndIf
    
    //once valueX  = StartingValue
    once PIncPos = 1 //Positive Increment Position
    once NIncPos = 1 //Negative Increment Position
    once optimise = 0 //Initialize Heuristicks Engine Counter (Must be Incremented at Position Start or Exit)
    once Mode1 = 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 optimise = Reps Then
    WinCountA = 0 //Initialize current Win Count
    StratAvgA = 0 //Initialize current Avg Strategy Profit
    HeuristicsCycle = HeuristicsCycle + 1
     
    For i = 1 to Reps Do
    If positionperf(i) > 0 Then
    WinCountA = WinCountA + 1 //Increment Current WinCount
    EndIf
    StratAvgA = StratAvgA + (((PositionPerf(i)*countofposition[i]*Close)*-1)*-1)
    Next
    StratAvgA = 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 Then
    StratAvgB = StratAvgA //Update Best Strategy Profit
    BestA = ValueX
    EndIf
    //once BestB = 300
    //GRAPH BestB coloured (0,0,0) AS "BestB"
    If WinCountA >= WinCountB Then
    WinCountB = WinCountA //Update Best Win Count
    BestB = ValueX
    EndIf
     
    If WinCountA > WinCountB and StratAvgA > StratAvgB Then
    Mode1 = 0
    ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode1 = 1 Then
    ValueX = ValueX - (Increment*NIncPos)
    NIncPos = NIncPos + 1
    Mode1 = 2
    ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode1 = 1 Then
    ValueX = ValueX + (Increment*PIncPos)
    PIncPos = PIncPos + 1
    Mode1 = 1
    ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode1 = 2 Then
    ValueX = ValueX + (Increment*PIncPos)
    PIncPos = PIncPos + 1
    Mode1 = 1
    ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode1 = 2 Then
    ValueX = ValueX - (Increment*NIncPos)
    NIncPos = NIncPos + 1
    Mode1 = 2
    EndIf
     
    If NIncPos > MaxIncrement or PIncPos > MaxIncrement Then
    If BestA = BestB Then
    ValueX = BestA
    Else
    If reps >= 10 Then
    WeightedScore = 10
    Else
    WeightedScore = round((reps/100)*100)
    EndIf
    ValueX = round(((BestA*(20-WeightedScore)) + (BestB*WeightedScore))/20) //Lower Reps = Less weight assigned to Win%
    EndIf
    NIncPos = 1
    PIncPos = 1
    ElsIf ValueX > MaxValue Then
    ValueX = MaxValue
    ElsIf ValueX < MinValue Then
    ValueX = MinValue
    EndIF
     
    optimise = 0
    EndIf
     
    // Heuristics Algorithm 1 End
    
    ElsIf HeuristicsAlgo2 = 1 Then
    
    // Heuristics Algorithm 2 Start
     
    If (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) Then
    optimise2 = optimise2 + 1
    EndIf
     
    //once ValueY = StartingValue2
    once PIncPos2 = 1 //Positive Increment Position
    once NIncPos2 = 1 //Negative Increment Position
    once optimise2 = 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 optimise2 = Reps2 Then
    WinCountA2 = 0 //Initialize current Win Count
    StratAvgA2 = 0 //Initialize current Avg Strategy Profit
    HeuristicsCycle = HeuristicsCycle + 1
     
    For i2 = 1 to Reps2 Do
    If positionperf(i2) > 0 Then
    WinCountA2 = WinCountA2 + 1 //Increment Current WinCount
    EndIf
    StratAvgA2 = StratAvgA2 + (((PositionPerf(i2)*countofposition[i2]*Close)*-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
    Mode2 = 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
    Mode2 = 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 = BestA2
    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
     
    optimise2 = 0
    EndIf
     
    // Heuristics Algorithm 2 End
    
    Endif
    #128202 quote
    GraHal
    Participant
    Master
    Would be nice to get Vonasi’s additional on/off switch code working
    Did you read below (click on blue link below) … Vonasi got logical results with and without his VRT code?
    returned one result that was identical to with the VRT code in the strategy but turned off.
    #128205 quote
    Bard
    Participant
    Master
    I’m not sure ValueY is “broken” when it flatlines, I think it’s more to do with the settings that the code. Let me take a look at the code above. Meanwhile can you please check the logic of your Long/Short BoxSize idea with my very simple entry conditions in Renko ML2 v3 below because the results are good not just on the Dow and £/$ but also on other instruments. I like to think a system is robust if it’s simple and can be applied to other markets particularly when you don’t have to alter settings to adjust for volatility. Great job.  
    //-------------------------------------------------------------------------
    // Main code : Nneless Renko DJI 1Month v3 Machine Learning (ML2)
    //https://www.prorealcode.com/topic/machine-learning-in-proorder/page/3/#post-121130
    //-------------------------------------------------------------------------
    //https://www.prorealcode.com/topic/why-is-backtesting-so-unreliable/#post-110889
    // Definition of code parameters
    
    //DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    //defparam preloadbars    = 1000
    //defparam flatbefore     = 080000
    //defparam flatafter      = 215500
    
    //
    //once tradetype        = 1 // [1]long&short;[2]long;[3]short
    //
    //once reenter          = 1
    //once positionperftype = 1 // [0] reenter always; [1] reenter positionperf < 0
    
    //ctime=time>=080000 and time<180000
    
    n=1
    
    HeuristicsCycleLimit = 2
    
    once HeuristicsCycle = 0
    once HeuristicsAlgo1 = 1
    once HeuristicsAlgo2 = 0
    
    If HeuristicsCycle >= HeuristicsCycleLimit Then
    If HeuristicsAlgo1 = 1 Then
    HeuristicsAlgo2 = 1
    HeuristicsAlgo1 = 0
    ElsIf HeuristicsAlgo2 = 1 Then
    HeuristicsAlgo1 = 1
    HeuristicsAlgo2 = 0
    EndIf
    HeuristicsCycle = 0
    EndIf
    
    If HeuristicsAlgo1 = 1 then
    
    //Heuristics Algorithm 1 Start
     
    If onmarket[1] = 1 and onmarket = 0 Then
    optimise = optimise + 1
    Endif
    
    //Settings 1 & 2
    
    StartingValue = 40 //5, 100, 10 Boxsize
    Increment     = 10 //5, 20, 10
    MaxIncrement  = 10 //5, 10 Limit of no of increments either up or down
    Reps          = 2 //1 Number of trades to use for analysis //2
    MaxValue      = 200 //20, 300, 150 //Maximum allowed value
    MinValue      = 5 //5, Minimum allowed value
    
    StartingValue2= 40 //5, 100, 50 Stop Loss
    Increment2    = 10 //5, 10
    MaxIncrement2 = 10 //1, 30 Limit of no of increments either up/down //4
    Reps2         = 2 //1, 2 Nos of trades to use for analysis //3
    MaxValue2     = 200 //20, 300, 200 Maximum allowed value
    MinValue2     = 5 //5, Minimum allowed value
     
    once ValueX = StartingValue
    once PIncPos = 1 //Positive Increment Position
    once NIncPos = 1 //Negative Increment Position
    once optimise = 0 //Initialize Heuristicks Engine Counter (Must be Incremented at Position Start or Exit)
    once Mode1 = 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 optimise = Reps Then
    WinCountA = 0 //Initialize current Win Count
    StratAvgA = 0 //Initialize current Avg Strategy Profit
    HeuristicsCycle = HeuristicsCycle + 1
     
    For i = 1 to Reps Do
    If positionperf(i) > 0 Then
    WinCountA = WinCountA + 1 //Increment Current WinCount
    EndIf
    StratAvgA = StratAvgA + (((PositionPerf(i)*countofposition[i]*Close)*-1)*-1)
    Next
    StratAvgA = 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 Then
    StratAvgB = StratAvgA //Update Best Strategy Profit
    BestA = ValueX
    EndIf
    //once BestB = 300
    //GRAPH BestB coloured (0,0,0) AS "BestB"
    If WinCountA >= WinCountB Then
    WinCountB = WinCountA //Update Best Win Count
    BestB = ValueX
    EndIf
     
    If WinCountA > WinCountB and StratAvgA > StratAvgB Then
    Mode1 = 0
    ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode1 = 1 Then
    ValueX = ValueX - (Increment*NIncPos)
    NIncPos = NIncPos + 1
    Mode1 = 2
    ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode1 = 1 Then
    ValueX = ValueX + (Increment*PIncPos)
    PIncPos = PIncPos + 1
    Mode1 = 1
    ElsIf WinCountA < WinCountB and StratAvgA < StratAvgB and Mode1 = 2 Then
    ValueX = ValueX + (Increment*PIncPos)
    PIncPos = PIncPos + 1
    Mode1 = 1
    ElsIf WinCountA >= WinCountB or StratAvgA >= StratAvgB and Mode1 = 2 Then
    ValueX = ValueX - (Increment*NIncPos)
    NIncPos = NIncPos + 1
    Mode1 = 2
    EndIf
     
    If NIncPos > MaxIncrement or PIncPos > MaxIncrement Then
    If BestA = BestB Then
    ValueX = BestA
    Else
    If reps >= 10 Then
    WeightedScore = 10
    Else
    WeightedScore = round((reps/100)*100)
    EndIf
    ValueX = round(((BestA*(20-WeightedScore)) + (BestB*WeightedScore))/20) //Lower Reps = Less weight assigned to Win%
    EndIf
    NIncPos = 1
    PIncPos = 1
    ElsIf ValueX > MaxValue Then
    ValueX = MaxValue
    ElsIf ValueX < MinValue Then
    ValueX = MinValue
    EndIF
     
    optimise = 0
    EndIf
     
    // Heuristics Algorithm 1 End
    
    ElsIf HeuristicsAlgo2 = 1 Then
    
    // Heuristics Algorithm 2 Start
     
    If onmarket[1] = 1 and onmarket = 0 Then
    optimise2 = optimise2 + 1
    Endif
     
    //Settings 2
     
    once ValueY = StartingValue2
    once PIncPos2 = 1 //Positive Increment Position
    once NIncPos2 = 1 //Negative Increment Position
    once optimise2 = 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 optimise2 = Reps2 Then
    WinCountA2 = 0 //Initialize current Win Count
    StratAvgA2 = 0 //Initialize current Avg Strategy Profit
    HeuristicsCycle = HeuristicsCycle + 1
     
    For i2 = 1 to Reps2 Do
    If positionperf(i2) > 0 Then
    WinCountA2 = WinCountA2 + 1 //Increment Current WinCount
    EndIf
    StratAvgA2 = StratAvgA2 + (((PositionPerf(i2)*countofposition[i2]*Close)*-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
    Mode2 = 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
    Mode2 = 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 = BestA2
    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
     
    optimise2 = 0
    EndIf
     
    // Heuristics Algorithm 2 End
    
    Endif
    
    boxSizeL = ValueX
    boxSizeS = ValueY
    
    renkoMaxL = ROUND(close / boxSizeL) * boxSizeL
    renkoMinL = renkoMaxL - boxSizeL
    
    renkoMaxS = ROUND(close / boxSizeS) * boxSizeS
    renkoMinS = renkoMaxS - boxSizeS
    
    IF high > renkoMaxL + boxSizeL THEN
    renkoMaxL = renkoMaxL + boxSizeL
    renkoMinL = renkoMinL + boxSizeL
    endif
    if low < renkoMinS - boxSizeS THEN
    renkoMaxS = renkoMaxS - boxSizeS
    renkoMinS = renkoMinS - boxSizeS
    ENDIF
    
    //
    
    //c1 = renkoMaxL + boxSizeL
    //c2 = renkoMinS - boxSizeS
    
    // Conditions to enter long positions
    //If c1 then
    Buy N CONTRACT at renkoMaxL + boxSizeL stop
    //EndIf
    
    // Conditions to enter short positions
    //If c2 then
    Sellshort N CONTRACT at renkoMinS - boxSizeS stop
    //EndIf
    
    
    // Stops and targets
    //SET STOP %loss 0.5
    
    Set stop ptrailing 50  //100
    SET TARGET PPROFIT 500 //Orig 150 //Best 500
    
    graphonprice renkomaxl + boxsizel coloured(0,200,0) as "renkomax"
    graphonprice renkomins - boxsizes coloured(200,0,0) as "renkomin"
    
    GRAPH ValueX coloured(0,255,0)
    GRAPH ValueY coloured(255,0,0)
    //graphonprice newsl coloured(0,0,255,255) as "trailingstop atr"
    
    Edit: What does adding once ValueX = StartingValue etc, do that it wasn’t doing before that code was added? Cheers.
    Silver-Renko-ML2-v3-Diff-BoxSizes-for-LongShort.png Silver-Renko-ML2-v3-Diff-BoxSizes-for-LongShort.png Brent-Renko-ML2-v3-Diff-BoxSizes-for-LongShort.png Brent-Renko-ML2-v3-Diff-BoxSizes-for-LongShort.png Dow-Renko-ML2-v3-Diff-BoxSizes-for-LongShort.png Dow-Renko-ML2-v3-Diff-BoxSizes-for-LongShort.png £-Renko-ML2-v3-Diff-BoxSizes-for-LongShort.png £-Renko-ML2-v3-Diff-BoxSizes-for-LongShort.png
Viewing 15 posts - 286 through 300 (of 455 total)
  • You must be logged in to reply to this topic.

Machine Learning in ProOrder ProRealTime


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
juanj @juanj Participant
Summary

This topic contains 454 replies,
has 32 voices, and was last updated by Khaled
4 years, 1 month ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 08/06/2017
Status: Active
Attachments: 207 files
Logo Logo
Loading...