dynamic live parameter adjustment

Viewing 15 posts - 16 through 30 (of 32 total)
  • Author
    Posts
  • #129887 quote
    Paul
    Participant
    Master

    @Francesco The code handles both ways, increase & decrease, with either direction and optimisation 0-1 finds out which is best. It’s based on the last trade result.

    win -> decrease angle; loss -> increase angle with direction 0

    loss -> decrease angle; win -> increase angle with direction 1

    I thought about it to be based on ratio mfa/mae, but that’s difficult!

    Francesco thanked this post
    #130126 quote
    Francesco
    Participant
    Veteran

    Hey Paul, i’m running a short timeframe system with your dinamic live parameter adjustment with the re-start everyday option. The first 3 days in the backtast it’s everything ok, then these last two days (the system is built to operate since 9 to 22), suddenly the system stop working after some hours.

    As you can see from the image, in the first day as the previous 2 everything is normal, then when the days after is restarted it suddenly stops and does not continue where the circle indicates.
    I also tried running the system only in the “suspected days” since another hour and it stops anyway. Any clue?

    2-7.jpg 2-7.jpg
    #130133 quote
    Francesco
    Participant
    Veteran

    Edit: Problem solved 🙂

    #130147 quote
    Paul
    Participant
    Master

    Great!

    Because of you suggestion francesco I started wondering if there are other ways. How it make it more self learning? Maybe this is a way?

    It focus on losses and you still ‘ve to pick a start direction with 0 or 1.

    for the boxsize for long (or angle long) it checks performance of the last trade,

    if it wins it sticks to the current directions/increments, however if it starts losing and when it reaches the min/max value, it swaps direction to do the opposite and so it’s less depended on a daily reset. Increments are now more important. If the minvalue->maxvalue is big with small increments it takes a while before a swap.

    that’s the idea.

    // dynamic parameter adjustment [OPPOSITE ON REACH MIN/MAX LEVEL WITH LOSSES)
    once periodr   = 0 // [0]none;[1]day;[2]week;[3]month;[4]year (reset period)
    once directionl= 0 // [0] or [1]opposite
    once directions= 0 // [0] or [1]opposite
    
    increment =  4
    minvalue  = 16
    maxvalue  = 32
    
    once valuex =  (minvalue+maxvalue)/2
    once valuey =  (minvalue+maxvalue)/2
    
    once startvalueL=24
    once startvalueS=24
    
    // main setup
    if periodr=0 then
    if barindex=0 then
    longperf=0
    shortperf=0
    endif
    elsif periodr=1 then
    if day<>day[1] then
    longperf=0
    shortperf=0
    endif
    elsif periodr=2 then
    if dayofweek=0 then
    longperf=0
    shortperf=0
    endif
    elsif periodr=3 then
    if month<>month[1] then
    longperf=0
    shortperf=0
    endif
    elsif periodr=4 then
    if year<>year[1] then
    longperf=0
    shortperf=0
    endif
    endif
     
    if longonmarket[1] and (not onmarket or shortonmarket) then
    if strategyprofit[1]>=strategyprofit[2] then
    longperf=longperf+positionperf(1)*100
    else
    longperf=longperf-positionperf(1)*100
    endif
    endif
     
    if shortonmarket[1] and (not onmarket or longonmarket) then
    if strategyprofit[1]>=strategyprofit[2] then
    shortperf=shortperf+positionperf(1)*100
    else
    shortperf=shortperf-positionperf(1)*100
    endif
    endif
    
    if directionl=1 then
    if longperf<>0 then
    if longperf>longperf[1] then
    if valuex+increment <= maxvalue then
    valuex=valuex+increment
    else
    valuex=valuex
    endif
    elsif longperf<longperf[1]  then
    if valuex-increment >= minvalue then
    valuex=valuex-increment
    else
    valuex=valuex
    directionl=0
    endif
    endif
    else
    valuex=startvalueL
    endif
    anglelong=valuex
    else
    if longperf<>0 then
    if longperf>longperf[1] then
    if valuex-increment >= minvalue then
    valuex=valuex-increment
    else
    valuex=valuex
    endif
    elsif longperf<longperf[1] then
    if valuex+increment <= maxvalue then
    valuex=valuex+increment
    else
    valuex=valuex
    directionl=1
    endif
    endif
    else
    valuex=startvalueL
    endif
    anglelong=valuex
    endif
    
    if directions=1 then
    if shortperf<>0 then
    if shortperf>shortperf[1] then
    if valuey+increment <= maxvalue then
    valuey=valuey+increment
    else
    valuey=valuey
    endif
    elsif shortperf<shortperf[1] then
    if valuey-increment >= minvalue then
    valuey=valuey-increment
    else
    valuey=valuey
    directions=0
    endif
    endif
    else
    valuey=startvalueS
    endif
    angleshort=valuey
    else
    if shortperf<>0 then
    if shortperf>shortperf[1] then
    if valuey-increment >= minvalue then
    valuey=valuey-increment
    else
    valuey=valuey
    endif
    elsif shortperf<shortperf[1] then
    if valuey+increment <= maxvalue then
    valuey=valuey+increment
    else
    valuey=valuey
    directions=1
    endif
    endif
    else
    valuey=startvalueS
    endif
    angleshort=valuey
    endif
    
    graph directions coloured(200,0,0)
    graph directionl coloured(0,200,0)
    
    
    graph valuex coloured(0,200,0) as "long value"
    graph valuey coloured(200,0,0) as "short value"
    eckaw, nonetheless and Francesco thanked this post
    #130202 quote
    Francesco
    Participant
    Veteran

    I encountered the problem again, I will try to test this new concept … thanks as usual 🙂

    #130212 quote
    Paul
    Participant
    Master

    encountered the problem again

    The first thing I think of is that you use used that little snippet and the value for losses  is set to 1 (%), so it stops trading after cumulative losses. It could be something else of-course and maybe it’s solved with above code.

    #130217 quote
    Francesco
    Participant
    Veteran

    The problematic was related to te bullish/bearish detection. Probably the exponential average values reach in some days, through the dynamic adjustment, a certain value that not opens new trades.

    Paul thanked this post
    #130250 quote
    Francesco
    Participant
    Veteran

    Ok, my bad, the problem was not related to a “stuck” in the average values…

    I noticed that removing these lines there’s no holes; but it brings the system to more lossess

    if longonmarket[1] and (not onmarket or shortonmarket) then
    if strategyprofit[1]>=strategyprofit[2] then
    longperf=longperf+positionperf(1)*100
    else
    longperf=longperf-positionperf(1)*100
    endif
    endif
    
    if shortonmarket[1] and (not onmarket or longonmarket) then
    if strategyprofit[1]>=strategyprofit[2] then
    shortperf=shortperf+positionperf(1)*100
    else
    shortperf=shortperf-positionperf(1)*100
    endif
    endif

    You was right 🙂

    Paul thanked this post
    #131786 quote
    Francesco
    Participant
    Veteran

    Hey Paul or everyone else, i would like to know if and how it’s possible to run an automatic system for a certain time range without using effective money but having it opening positions in “background” (we talked about this time ago in the renk discussion). Then after a time trigger (or a strategyprofit trigger) starting using capital for the position opening.

    #131801 quote
    juanj
    Participant
    Master

    This is tricky but I have done it before. Basically you need to ‘virtually’ take the positions using the same rules and then keep track of their virtual performance. I use variables called IsLong and IsShort along with variables called LongEntryLevel and ShortEntryLevel

    Francesco thanked this post
    #131807 quote
    swedshare
    Participant
    Senior

    Francesco, could this be something you’re looking for:

    https://www.prorealcode.com/blog/learning/how-to-improve-a-strategy-with-simulated-trades-1/

    Francesco thanked this post
    #131825 quote
    Vonasi
    Moderator
    Master

    There is also this topic that might be of interest:

    Simulated Trading

    Francesco thanked this post
    #131834 quote
    zilliq
    Participant
    Master

    Francesco, could this be something you’re looking for:

    https://www.prorealcode.com/blog/learning/how-to-improve-a-strategy-with-simulated-trades-1/

    The very good code of Nicolas is only for short 😉

    #137809 quote
    Francesco
    Participant
    Veteran

    I was thinking in the case of low tf systems (>30) in order to avoid an hypotetical overfitting of the ML values (max,min,start): what if (using the daily reset mode) we put yesterday’s optimized parameters for tomorrow operativity and going on like this? That reduces the possibility to have ML overfitting based on the fact that the markets does not drastically changes day by day. With this kind of solution we can evolve the ML values in parallel to the changes of the market. Have everyone tried to run a system for a week using last week 200k ML values vs a system for a week with daily optimized values based on yesterday?

    I don’t know if i explained myself well, but i hope this can be understandable and interesting 🙂

    #139693 quote
    Francesco
    Participant
    Veteran

    Sorry if I am clogging this topic continuously but I need a suggestion about an idea.

    I would like to know if it’s possible to create a dynamic parameter adjustment like this:

    I choose an interval for a parameter of my strategy (for example 10-1000) like the original Paul’s dynamic live parameter adjustment code.
    Then, the machine learning algorithm after the closing of the first trade of the day select the most profitable parameter on it between the interval and fix it on the strategy for the rest of the day (so there’s not a continuous fixing trade by trade and not by starting from a parameter and moving following a selected increment value); then there’s the reset for the day after. If it’s possible the first trade of the day should be simulated somehow in order to avoid losses with the vonasi’s simulated trading hint, but it’s not fundamental, I can also achieve a loss starting from a random parameter, the important is having the best one of the first trade fixed for the rest of the day.

    Is something like this possible? How? I would be really grateful if you can help me because this could be very important for a strategy that I’m developing 🙂

Viewing 15 posts - 16 through 30 (of 32 total)
  • You must be logged in to reply to this topic.

dynamic live parameter adjustment


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Paul @micky75d Participant
Summary

This topic contains 31 replies,
has 8 voices, and was last updated by Francesco
5 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 03/02/2020
Status: Active
Attachments: 4 files
Logo Logo
Loading...