Machine Learning in ProOrder ProRealTime

Viewing 15 posts - 406 through 420 (of 455 total)
  • Author
    Posts
  • #130532 quote
    Vonasi
    Moderator
    Master

    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.

    Bard thanked this post
    #145817 quote
    Fantasio2020
    Participant
    Senior

    Hi 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

    #145843 quote
    Francesco
    Participant
    Veteran

    Hi 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

    #145851 quote
    Fantasio2020
    Participant
    Senior

    I 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?

    #145949 quote
    GraHal
    Participant
    Master

    Is 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?

    #145992 quote
    Paul
    Participant
    Master

    playing 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.

    #146013 quote
    GraHal
    Participant
    Master

    looking 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’.

    #146074 quote
    Fantasio2020
    Participant
    Senior

    Is 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

    #146077 quote
    GraHal
    Participant
    Master

    no more than 4 days

    Yeah same for all of us  … 4 days max on 10 sec TF using v10.3! 🙁

    #146112 quote
    Paul
    Participant
    Master

    You 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.

    GraHal thanked this post
    #146665 quote
    Paul
    Participant
    Master

    again 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.

    // heuristics engine
    if heuristicsengine then
    
    StartingValue   = aa
    increment       = 1 //5, 20, 10
    maxincrement    = 2 //5, 10 limit of no of increments either up or
    reps            = 1  //1 number of trades to use for analysis //2
    maxvalue        = 10 //20, 300, 150 //maximum allowed 12
    minvalue        = 2 //5, minimum allowed value
     
    StartingValue2 = bb
    increment2      = 1 //5, 10
    maxincrement2   = 2 //1, 30 limit of no of increments either up/down //4
    reps2           = 1  //1, 2 nos of trades to use for analysis //3
    maxvalue2       = 10 //20, 300, 200 maximum allowed value
    minvalue2       = 2 //5, minimum allowed value
    
    reset           = 1
    weighting       = 0
    
    if reset=1 then
    if openhour=0 then
    ValueX = StartingValue
    Valuey = StartingValue2
    WinCountB = 0
    WinCountB2 = 0
    StratAvgB = 0
    StratAvgB2 = 0
    BestA = 0
    BestA2 = 0
    BestB = 0
    BestB2 = 0
    wincounta = 0 //initialize current win count
    stratavga = 0 //initialize current avg strategy profit
    wincounta2 = 0 //initialize current win count
    stratavga2 = 0 //initialize current avg strategy profit
    endif
    else
    once ValueX = StartingValue
    once Valuey = StartingValue2
    once WinCountB = 0
    once WinCountB2 = 0
    once StratAvgB = 0
    once StratAvgB2 = 0
    once BestA = 0
    once BestA2 = 0
    once BestB = 0
    once BestB2 = 0
    
    endif
    
    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 = a1 //positive increment position
    once nincpos = a2 //negative increment position
    once 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 then
    
    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 = min((valuex + (increment*pincpos)),maxvalue)
    pincpos = pincpos + 1
    mode1 = 1
    elsif wincounta < wincountb and stratavga < stratavgb and mode1 = 2 then
    valuex = min((valuex + (increment*pincpos)),maxvalue)
    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 weighting=1 then
    If reps >= 10 Then
    WeightedScore = 10
    Else
    WeightedScore = round((reps/100)*100)
    EndIf
    ValueX1 = min(round(((BestA*(20-WeightedScore)) + (BestB*WeightedScore))/20),maxvalue) //Lower Reps = Less weight assigned to Win%
    valuex=max(minvalue,valuex1)
    EndIf
    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 = a3 //positive increment position
    once nincpos2 = a4 //negative increment position
    once 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 then
    
    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 = min((valuey + (increment2*pincpos2)),maxvalue2)
    pincpos2 = pincpos2 + 1
    mode2 = 1
    elsif wincounta2 < wincountb2 and stratavga2 < stratavgb2 and mode2 = 2 then
    valuey = min((valuey + (increment2*pincpos2)),maxvalue2)
    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 weighting=1 then
    If reps2 >= 10 Then
    WeightedScore2 = 10
    Else
    WeightedScore2 = round((reps2/100)*100)
    EndIf
    ValueY1 = min(round(((BestA2*(20-WeightedScore2)) + (BestB2*WeightedScore2))/20),maxvalue2)
    valuey=max(minvalue2,valuey1)
    //Lower Reps = Less weight assigned to Win%
    EndIf
    endif
    nincpos2 = 1
    pincpos2 = 1
    elsif valuey > maxvalue2 then
    valuey = maxvalue2
    elsif valuey < minvalue2 then
    valuey = minvalue2
    endif
     
    optimise2 = 0
    endif
    endif
    // heuristics algorithm 2 end
    n=valuex
    multiple=valuey
    else
    n=valuen
    multiple=valuem
    endif
    
    #146671 quote
    snucke
    Participant
    Veteran

    ive expericed the same issue, when testing on one timeframe then switch to another and then back the results are not even close to the same as when the first test occured, and no values was changed in between.

    #146676 quote
    Fantasio2020
    Participant
    Senior

    How many variables can we consider working with …

    Personally, I work with a strategy on which I can adjust up to 7 variables …

    #146677 quote
    Paul
    Participant
    Master

    yes 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

    Screenshot-2020-10-07-at-17.24.20.png Screenshot-2020-10-07-at-17.24.20.png testcase-H-engine-m2.itf
    #146698 quote
    GraHal
    Participant
    Master

    the 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?

Viewing 15 posts - 406 through 420 (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...