Machine Learning in ProOrder ProRealTime

Viewing 15 posts - 181 through 195 (of 455 total)
  • Author
    Posts
  • #127227 quote
    nonetheless
    Participant
    Master

    Sorry for the Mission Drift – I actually thought we were in the Pure Renko strategy  thread…

    #127232 quote
    GraHal
    Participant
    Master

    It is selected in the screenshot. If you’re seeing that unselected somewhere else, it was probably 2am…

    Maybe you did a lot of tests and posting of results at 2 am (?) because to reproduce your results on coffee I have to disable tick by tick mode.

    However, the Daily TF on DJI (I think?) that I posted was with tick by tick enabled.

    We need to get the bottom of this anyway … I’m glad a few of us are now looking at it!? 🙂

    Vonasi’s keeping quiet, now I know why … he’s already bought his new yacht complete with onboard tropical island!!!! 🙂

    Yacht.jpg Yacht.jpg
    #127235 quote
    GraHal
    Participant
    Master

    Attached is what I get on coffee with tick by tick enabled … too much caffeine for me .. I’ll never sleep!! 🙂

    Bard-2.jpg Bard-2.jpg Bard-7.jpg Bard-7.jpg
    #127240 quote
    Finning
    Participant
    Veteran

    Forgot to click on tick by tick before-done that… even with daily bars this is a problem.

    Capture-2.jpg Capture-2.jpg
    #127244 quote
    Bard
    Participant
    Master

    Thanks for clarifying @Nonetheless. In your opinion, because I have not read through all of that forum thread, was that a mistake using version 1 because v2 performed better than the very first Renko algo?
    I actually couldn’t get v1 to work on the 1 minute TF, hence me thinking maybe it was meant to be 1 month (which I never usually backtest on) and then discovering it worked really well with that TF, I decided to add the ML code to see what would happen… the rest, as they say is a “happy accident.”

    #127245 quote
    Bard
    Participant
    Master

    I’ve been going back through Juanj’s original code carefully: https://www.prorealcode.com/topic/machine-learning-in-proorder/page/3/#post-121130

    Is line 166 and 169 (now lines 2 and 5) correct?

    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

    Perhaps a little mistake, because surely it should read “(i2)” not (i), right? :

    For i2 = 1 to Reps2 Do
    If positionperf(i2) > 0 Then
    WinCountA2 = WinCountA2 + 1 //Increment Current WinCount
    EndIf
    StratAvgA2 = StratAvgA2 + (((PositionPerf(i2)*countofposition[i]*100000)*-1)*-1)
    #127247 quote
    Bard
    Participant
    Master

    ** and should countofposition also be “(i2)?”

    #127249 quote
    nonetheless
    Participant
    Master

    was that a mistake using version 1

    The subsequent versions were far more sophisticated, for sure, and some have ML applied, for example #126632

    1m in the original was def 1 minute but I never kept it on forward testing for that long. @Grahal had a lot of success with it

    Bard thanked this post
    #127250 quote
    GraHal
    Participant
    Master

    then discovering it worked really well

    Glad you did!

    I’ve often found new and better ways through life by doing something wrong in the first place! 🙂

    Perhaps a little mistake, because surely it should read “(i2)” not (i), right? :

    I agree! well spotted!

    Also the 100000 should read Close or a value related to the Price of instrument under test.

    Bard thanked this post
    #127259 quote
    Bard
    Participant
    Master

    Thanks very much for the clarification @Nonetheless. Do you know what the “ha” stands for in front of the high in Renko3?
    So that’s 2 more  different versions to test and apply ML1 and ML2 too. I’m going to be here for years…

    #127260 quote
    Bard
    Participant
    Master

    Sorry for the Mission Drift..

    I’m just waiting for my brother to tell me it’s okay, that I can leave my computer…

    #127261 quote
    GraHal
    Participant
    Master

    ** and should countofposition also be “(i2)?”

    Yes I would say so.

    It’s a pity @Juanj hasn’t dropped by for a while? He also may be working with these errors.

    One way I noticed errors early on in my trialling the HAlgos is … I used Halgo2 as stand alone / on it’s own  in a System. When I tried to backtest it told me about 3 or 4 variables were not defined. I then realised that HAlgo2 had been using values from HAlgo1.

    You could try above as a check on your HAlgo2 and also HAlgo3.

    Bard thanked this post
    #127265 quote
    nonetheless
    Participant
    Master

    what the “ha” stands for

    HA = heikin ashi, an alternative Japanese candle-type

    Bard thanked this post
    #127268 quote
    Bard
    Participant
    Master

    It’s giving me the same kind of results (in the millions with 30x capital). In fact it seems to have picked up a “spare £13 million”… Not sure @GraHal, is anyone else able to replicate these results?
    Maybe there is a caching issue and even though it shows tick by tick it’s not doing tick by tick, although I have started a fresh session in PRT this morning and get the same high results.
    Maybe the other day I had other backtests running in the same chart and when I changed the TF of coffee it would show me a warning saying that tick by tick wasn’t available for the date range for another system (and I did click for it to test the new TF without tick by tick, but perhaps it was also unticking my Renko ML1 StpLoss system, (although it’s not visually removing my tick in the tick by tick backtest box)?

    Here’s the code instead of the itf: The only change is with:

    StratAvgA = StratAvgA + (((PositionPerf(i)*countofposition[i]*100000)*-1)*-1)

    where I replaced 100,000 with Close. Oddly no difference in profit on Coffee although it did make a big difference when I made that change for the Ehlers’ Univ Osc ML2 system with coffee?

    //-------------------------------------------------------------------------
    // Main code : Nneless Renko DJI 1M v1 ML1 Cycle Limit Reset - 
    // Orig a 1 Min system (no ML), then 1 Month (no ML) and then 1 Month with ML and now Daily with ML
    // The 30 x capital was a test to break the system.
    //-------------------------------------------------------------------------
    //https://www.prorealcode.com/topic/why-is-backtesting-so-unreliable/#post-110889
    // Definition of code parameters
    
    DEFPARAM CumulateOrders = False // Cumulating positions deactivated
    // The system will cancel all pending orders and close all positions at 0:00. No new ones will be allowed until after the "FLATBEFORE" time.
    //DEFPARAM FLATBEFORE = 143000
    // Cancel all pending orders and close all positions at the "FLATAFTER" time
    //DEFPARAM FLATAFTER = 210000
    
    Capital = 10000 + strategyprofit //Current profit made by the closed trades of the running strategy.
    
    N = 30*Capital / Close //30
    
    //ValueX for the Renko Stop Loss.
    
    //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
    
    //Settings 1
    
    StartingValue = 10 //10 Stop Loss
    ResetPeriod = 0.5 //0.5 Specify no of months after which to reset optimisation
    Increment = 5 //20
    MaxIncrement = 10 //10 Limit of no of increments either up or down
    Reps = 2 //Number of trades to use for analysis //2
    MaxValue = 150 //150 //Maximum allowed value
    MinValue = increment //Minimum allowed value
    
    once monthinit = month
    once yearinit = year
    If (year = yearinit and month = (monthinit + ResetPeriod)) or (year = (yearinit + 1) and ((12 - monthinit) + month = ResetPeriod)) Then
    ValueX = StartingValue
    WinCountB = 0
    StratAvgB = 0
    BestA = 0
    BestB = 0
    monthinit = month
    yearinit = year
    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
    
    //Renko Definitions
    
    boxSize = 100 // Orig 110
    
    //StartingValue = 10 //10 Stop Loss
    //ResetPeriod = 0.5 //0.5 Specify no of months after which to reset optimisation
    //Increment = 5 //20
    //MaxIncrement = 10 //10 Limit of no of increments either up or down
    //Reps = 2 //Number of trades to use for analysis //2
    //MaxValue = 150 //150 //Maximum allowed value
    //MinValue = increment //Minimum allowed value
    
    once renkoMax = ROUND(close / boxSize) * boxSize
    once renkoMin = renkoMax - boxSize
    
    IF high > renkoMax + boxSize THEN
    WHILE high > renkoMax + boxSize
    renkoMax = renkoMax + boxSize
    renkoMin = renkoMin + boxSize
    WEND
    ELSIF low < renkoMin - boxSize THEN
    WHILE low < renkoMin - boxSize
    renkoMax = renkoMax - boxSize
    renkoMin = renkoMin - boxSize
    WEND
    ENDIF
    
    c1 = renkoMax + boxSize
    c2 = renkoMin - boxSize
    
    // Conditions to enter long positions
    If c1 then
    Buy N CONTRACT at renkoMax + boxSize stop
    EndIf
    
    // Conditions to enter short positions
    If c2 then
    Sellshort N CONTRACT at renkoMin - boxSize stop
    EndIf
    
    // Stops and targets
    //SET STOP PLOSS ValueX //Orig 75
    Set stop trailing ValueX//100
    SET TARGET PPROFIT 500 //Orig 150
    
    GRAPH ValueX coloured(0,255,0)
    
    Renko-1M-ML1-StpLoss-30-x-Capital-Coffee-Daily-£68m-681250-Win-55-Gainloss-6.8-DDown-8-19092018-15042020-WITH-SPREAD.-and-TICK-by-TICK.png Renko-1M-ML1-StpLoss-30-x-Capital-Coffee-Daily-£68m-681250-Win-55-Gainloss-6.8-DDown-8-19092018-15042020-WITH-SPREAD.-and-TICK-by-TICK.png
    #127273 quote
    Bard
    Participant
    Master

    Maybe Vonasi’s hard to reach because he bought a nuclear sub instead!? 😀

    GraHal thanked this post
    submarine.jpg submarine.jpg
Viewing 15 posts - 181 through 195 (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...