MTF, with or without UPDATEONCLOSE?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #215605 quote
    phoentzs
    Participant
    Master

    I would like to ask for your opinions here… When I use MTF, I use it in this form:

    timeframe(240minute, updateonclose)

    Now, more by accident, I omitted this “updateonclose” and my strategies somehow seem “rounder” with more power. The only way I can explain it is that the signal with “updateonclose” when used with an H4-TF comes 4 hours “later” and is valid for exactly 4 hours. If the signal is no longer available within these 4 hours, the system only notices it 4 hours later.
    If I now set up a system without “updateonclose”, the system reacts almost immediately if a signal is present or not. That means it reacts faster… maybe more nervous?
    Does anyone have experience with it? Can anyone give me their opinion on which is better? I’m a bit afraid of over-optimization…

    #215606 quote
    GraHal
    Participant
    Master

    What is / are  the other Timeframe(s) in your code?

    If it were me I would updateonclose  or not use updateonclose depending on which gives the ‘best’ results taking all performance factors into account?

    Maybe if you post an equity curve with positions under equity curve and price curve under positions then we might be able advise somethng moe meaningful?

    #215607 quote
    druby
    Participant
    New

    Hi phoentzs.

    Omitting the ‘UPDATEONCLOSE’ is a shortcut, and is the same as replacing it with ‘DEFAULT’.

    The difference between them is, ‘when’ the data covered by the ‘TIMEFRAME’ is updated.

    ‘UPDATEONCLOSE’ – uses the close of the specified timeframe.

    ‘DEFAULT’ – uses the close of the ‘Chart Timeframe’ , I guess could be known as ‘TIMEFRAME(DEFAULT,DEFAULT)’.

    Using the ‘DEFAULT’ option, updates the ‘TIMEFRAME’ values at a higher frequency since the ‘TIMEFRAME’s time value is, and has to be a multiple of the default/chart timeframe.

    e.g. if [ , ] was an update and chart 1h

    updateonclose-v-default

    8h …….,…….,-v-,,,,,,,,,,,,,,,,

    4h …,…,…,…,-v-,,,,,,,,,,,,,,,,

    1h ,,,,,,,,,,,,,,,,-v-,,,,,,,,,,,,,,,,

    Regarding which is better – the best you can due is backtest both against each other based on what your doing. At least you will be able to see the differences between them and ‘Know’ which is better.

    Regards

    #215608 quote
    phoentzs
    Participant
    Master

    I don’t have a laptop here right now otherwise I could visualize it… I mostly use inputs in the TF M1 and get an overall trend from higher timeframes. This can be the M15 or the H4. If I remove UPDATEONCLOSE from an M15-TF, the system becomes very nervous and worse. But for systems that get signals from H1 or H4, removing UPDATEONCLOSE will make the system more powerful, with more positions and a quasi-similar drawdown. Which leads me to think that would be better in this case. I think there are just more opportunities for the M1-TF to take good positions. At least that’s what it looks like.

    #215609 quote
    phoentzs
    Participant
    Master

    In sideways phases, however, there is also the risk that several bad positions will be taken one after the other.

    #215614 quote
    robertogozzi
    Moderator
    Master

    It’s a personal choice, whether to use signals while a candle is being formed or wait for its closing.

    That’s what MTF is for, before that you could only wait for its closing, now you have a choice.

    I prefer waiting the closing to enter a position and use the live data to confirm it. This code will enter on a SMA crossover, on a 4h-timefrane, provided on the Daily TF the SMA is currently rising. You may use it on a 4h-timeframe or lower:

    DEFPARAM CumulateOrders = False
    //
    Timeframe(Daily,default)
    SmaD = average[20,0](close)
    //
    Timeframe(4h,UpdateOnClose)
    Sma4 = average[20,0](close)
    IF (close CROSSES OVER Sma4) AND (SmaD > SmaD[1]) THEN
    BUY AT MARKET
    SET TARGET pPROFIT 300
    SET  STOP  pLOSS   150
    ENDIF
    //
    Timeframe(default)
    //*********************************************************************************
    // https://www.prorealcode.com/blog/trading/complete-trailing-stop-code-function/
    // (lines 17- 56)
    //
    //trailing stop function
    trailingstart = 10   //trailing will start @trailinstart points profit
    trailingstep  = 1    //trailing step to move the "stoploss"
     
    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF
     
    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF
     
    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF
     
    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF
    //*********************************************************************************
    #215630 quote
    phoentzs
    Participant
    Master

    That’s how I mean it too. Trend signals from upper TF without UPDATEONCLOSE and entry signal with UPDATEONCLOSE. My entries are usually created in TF (default).

    #216633 quote
    phoentzs
    Participant
    Master

    I have to ask one more question to understand better. If I use a SMA20 from the TF H1 without updateonclose in the TF M1… is that exactly the same as a SMA1200 from the TF M1?

    #216634 quote
    GraHal
    Participant
    Master

    I just did a test using Cursor Details, real easy to do, but best done while price is not moving (21:15 to 21:30 UK time on DJI).

    I switched between TF’s – 1 min TF (MA1200) and 1 hour (MA20) – and value was the same (within the limitations of above error – 0.1 diff on DJI).

    phoentzs thanked this post
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.

MTF, with or without UPDATEONCLOSE?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
phoentzs @phoentzs Participant
Summary

This topic contains 8 replies,
has 4 voices, and was last updated by GraHal
2 years, 7 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 06/03/2023
Status: Active
Attachments: No files
Logo Logo
Loading...