MultiTimeFrame simple conditions

Viewing 15 posts - 16 through 30 (of 33 total)
  • Author
    Posts
  • #89845 quote
    Leo
    Participant
    Veteran

    Ahhh.. I got it. Thanks

    #89865 quote
    jebus89
    Participant
    Master

    I heard an episode of the podcast “better system trader” with a “mean reversion expert”, i cant remember name or episode tho, its one of the older ones. he talks alot about how he uses the RSI in 4 hour and 1 hour (mtf) to create good strategies. Im working on RSI in mtf now and seeing some interesting results, nothing amazing so far tho, pic includes the latest im working on, first algo ive seen working in EU stox so im kinda happy with that, but yea no amazing results so far but im gonna optimize it now and see what happens..

     

    Its long and short, i like to optimize the long and short seperatly to increase the speed of the optimization. As long as i already know that it will not affect the other long/short strategy i figured that should be safe and fine to do, and it saves me a ton of time either optimizing long or short 1 at a time or optimizing them together which could take hours..

    GraHal thanked this post
    eustox.png eustox.png
    #89867 quote
    Leo
    Participant
    Veteran

    Hi all,

    Here I upload my version…

    I like this concept, I called it: MULTI-SIMPLICITY TYPE A

     

    // MULTI-SIMPLICITY TYPE A
    DEFPARAM CumulateOrders = false // Cumulating positions
    DEFPARAM PreLoadBars = 1000 //cargar informacion
    
    //Parameters to be optimized
    //Pentry1=6
    //Kprofit=1.5
    
    
    ontime=1
    IF hour <= 2 or hour >= 22 then
    ontime=0
    ELSIF DayOfWeek <= 1 and hour <= 4 then
    ontime=0
    ELSIF DayOfWeek >= 5 and hour >= 20 then
    ontime=0
    ENDIF
    
    MetaRange=max(pipsize,pipsize*round(average[34](average[21](average[13](average[8](average[5](round(range/pipsize))))))))
    
    /////////// LEO CHANNEL  //////////////////
    PXentry1=max (2, round(0.6*Pentry1) )
    highest1=highest[Pentry1](high)
    IF highest1 = highest1[PXentry1] then
    Re1=highest1
    ENDIF
    IF high > Re1 then
    Re1=high
    ENDIF
    lowest1=lowest[Pentry1](low)
    IF lowest1 = lowest1[PXentry1] then
    S1=lowest1
    ENDIF
    If low < S1 then
    S1=low
    ENDIF
    
    ConditionLong00001= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
    ConditionShort00001= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
     
    timeframe(15 minutes,updateonclose)
    ConditionLong00002= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
    ConditionShort00002= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
    
    timeframe(30 minutes,updateonclose)
    ConditionLong00003= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
    ConditionShort00003= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
     
    timeframe(60 minutes,updateonclose)
    ConditionLong00004= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
    ConditionShort00004= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
     
    timeframe(120 minutes,updateonclose)
    ConditionLong00005= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
    ConditionShort00005= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
     
    timeframe(240 minutes,updateonclose)
    ConditionLong00006= close>average[20](close) and average[20](Close[1])>average[20](Close) and lowest[5](low) > average[200](Close) and average[200](Close[1])<average[200](Close)
    ConditionShort00006= close<average[20](close) and average[20](Close[1])<average[20](Close) and highest[5](high) < average[200](Close) and average[200](Close[1])>average[200](Close)
    
    timeframe(default)
     
    ConditionLong = ConditionLong00001 + ConditionLong00002 + ConditionLong00003 + ConditionLong00004  + ConditionLong00005  + ConditionLong00006
    ConditionShort = ConditionShort00001 +ConditionShort00002+ ConditionShort00003+ConditionShort00004+ConditionShort00005+ConditionShort00006
    
    //----------------------------------------------------------
    //   >>>>>>>>>>>>>>   ENTRY POSITIONS    <<<<<<<<<<<<<<<<<<
    //----------------------------------------------------------
    
    //  ---> LONG POSITIONS
    IF NOT LongOnMarket and ontime=1 THEN
    IF ConditionLong > 2 THEN
    stoplosslong= (close-S1)/pipsize+2*MetaRange/pipsize//in pips
    targetprofitlong=stoplosslong*Kprofit //in pips
    BUY 1 CONTRACTS AT MARKET
    SET STOP pLOSS stoplosslong
    SET TARGET pPROFIT targetprofitlong
    ENDIF
    ENDIF
    
    //  ---> SHORT POSITIONS
    IF NOT ShortOnMarket and ontime=1 THEN
    IF ConditionShort > 2 THEN
    StopLossShort=(Re1-close)/pipsize+2*MetaRange/pipsize // in pips
    targetprofitshort=StopLossShort*Kprofit // in pips
    SELLSHORT 1 CONTRACTS AT MARKET
    SET STOP pLOSS  StopLossShort
    SET TARGET pPROFIT targetprofitshort
    ENDIF
    ENDIF
    
    //---------------------------------------------------------
    //>>>>>>>>>>>>>>>>>>   EXIT POSITIONS    <<<<<<<<<<<<<<<<<<
    //---------------------------------------------------------
    If LongOnMarket THEN
    
    //////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE  ////////////////
    //If close > TRADEPRICE+targetprofitlong*pipsize THEN
    //SELL  AT MARKET
    //ENDIF
    //IF close  <  TRADEPRICE-stoplosslong*pipsize THEN
    //SELL  AT MARKET
    //ENDIF
    IF highest[BARINDEX-TRADEINDEX+1](high) > TRADEPRICE+0.75*stoplosslong*pipsize and (BARINDEX-TRADEINDEX)>=2 THEN
    Kexit=((TRADEPRICE+targetprofitlong*pipsize)-highest[BARINDEX-TRADEINDEX+1](high)) / ( (TRADEPRICE+targetprofitlong*pipsize) - (TRADEPRICE+0.75*stoplosslong*pipsize))
    IF low < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize and close < typicalprice  then
    SELL AT MARKET
    ELSIF close < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize THEN
    SELL AT MARKET
    ENDIF
    ENDIF
    
    ////////////////////////////
    
    IF CLOSE < S1[1] THEN
    SELL AT MARKET
    ENDIF
    
    IF high > TRADEPRICE + 0.75*stoplosslong*pipsize THEN
    SET STOP pLOSS 0.01
    ENDIF
    
    IF TIME > 214500 and DayOfWeek=5 then
    SELL AT MARKET
    ENDIF
    ENDIF
    
    // Bedingungen zum Ausstieg aus Short-Positionen
    IF ShortOnMarket THEN
    //////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE  ////////////////
    //IF close < TRADEPRICE-targetprofitshort*pipsize THEN
    //EXITSHORT AT MARKET
    //ENDIF
    //IF close > TRADEPRICE+stoplossshort*pipsize THEN
    //EXITSHORT AT MARKET
    //ENDIF
    IF lowest[BARINDEX-TRADEINDEX+1](low) < TRADEPRICE-0.75*stoplossshort*pipsize  and (BARINDEX-TRADEINDEX)>=2THEN
    Kexit=(lowest[BARINDEX-TRADEINDEX+1](low)-(TRADEPRICE-TargetProfitShort*pipsize) ) / ( (TRADEPRICE-0.75*stoplossshort*pipsize)-(TRADEPRICE-TargetProfitShort*pipsize))
    IF high > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize and close > typicalprice THEN
    EXITSHORT AT MARKET
    ELSIF close > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize THEN
    EXITSHORT AT MARKET
    ENDIF
    ENDIF
    
    ////////////////////////////////
    
    IF CLOSE > Re1[1] THEN
    EXITSHORT AT MARKET
    ENDIF
    
    IF low < TRADEPRICE - 0.75*stoplossshort*pipsize THEN
    SET STOP pLOSS 0.01
    ENDIF
    
    IF TIME > 214500 and DayOfWeek=5 then
    EXITSHORT AT MARKET
    ENDIF
    
    ENDIF
    
    Screen-Shot-2019-01-28-at-21.59.38.png Screen-Shot-2019-01-28-at-21.59.38.png
    #89869 quote
    Leo
    Participant
    Veteran

    Jebus89… It looks very nice.

    Can you share the conditions… I have several ideas about RSI as well like

    ConditionLong00001=RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<30
    #89870 quote
    Leo
    Participant
    Veteran

    I like this concept, I called it: MULTI-SIMPLICITY TYPE A

    Here the walk forward

    Screen-Shot-2019-01-28-at-21.59.38-1.png Screen-Shot-2019-01-28-at-21.59.38-1.png
    #89875 quote
    jebus89
    Participant
    Master

    its nothing atm just trying out something like:

    (this is short, reverse for long)

    timeframe daily: rsi 2 > 95

    timeframe 4 hours: rsi 2 > 95

    timeframe 1 hour: rsi crosses under 95

     

    Sell at daily timeframe when rsi 2 crosses under 30

     

    I think its very easy to curvefit something like this so im very sceptical but honestly it also looks applicable in different markets.

    #89877 quote
    jebus89
    Participant
    Master

    then again if its easy to curvefit, maybe some reoptimizing every x month might work wonders… gonna walk it forward and see what happens, obviously no stop, no traget, no trailing, no filter has been added..

    #89880 quote
    Leo
    Participant
    Veteran

    I just made  something with RSI, looks very nice as well

    // MULTI-SIMPLICITY TYPE A
    DEFPARAM CumulateOrders = false // Cumulating positions
    DEFPARAM PreLoadBars = 1000 //cargar informacion
    
    //Parameters to be optimized
    //Pentry1=6
    //Kprofit=1.5
    //Krsi=30
    
    
    ontime=1
    IF hour <= 2 or hour >= 22 then
    ontime=0
    ELSIF DayOfWeek <= 1 and hour <= 4 then
    ontime=0
    ELSIF DayOfWeek >= 5 and hour >= 20 then
    ontime=0
    ENDIF
    
    MetaRange=max(pipsize,pipsize*round(average[34](average[21](average[13](average[8](average[5](round(range/pipsize))))))))
    
    /////////// LEO CHANNEL  //////////////////
    PXentry1=max (2, round(0.6*Pentry1) )
    highest1=highest[Pentry1](high)
    IF highest1 = highest1[PXentry1] then
    Re1=highest1
    ENDIF
    IF high > Re1 then
    Re1=high
    ENDIF
    lowest1=lowest[Pentry1](low)
    IF lowest1 = lowest1[PXentry1] then
    S1=lowest1
    ENDIF
    If low < S1 then
    S1=low
    ENDIF
    
    ConditionLong00001= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
    ConditionShort00001= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
     
    timeframe(15 minutes,updateonclose)
    ConditionLong00002= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
    ConditionShort00002= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
    timeframe(30 minutes,updateonclose)
    ConditionLong00003= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
    ConditionShort00003= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
    timeframe(60 minutes,updateonclose)
    ConditionLong00004= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
    ConditionShort00004= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
    timeframe(120 minutes,updateonclose)
    ConditionLong00005= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
    ConditionShort00005= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
     
    timeframe(240 minutes,updateonclose)
    ConditionLong00006= RSI[14](close) > average[14](RSI[14](close)) and lowest[7](RSI[14](close))<Krsi
    ConditionShort00006= RSI[14](close) < average[14](RSI[14](close)) and Highest[7](RSI[14](close))>100-Krsi
    timeframe(default)
     
    ConditionLong = ConditionLong00001 + ConditionLong00002 + ConditionLong00003 + ConditionLong00004  + ConditionLong00005  + ConditionLong00006
    ConditionShort = ConditionShort00001 +ConditionShort00002+ ConditionShort00003+ConditionShort00004+ConditionShort00005+ConditionShort00006
    
    //----------------------------------------------------------
    //   >>>>>>>>>>>>>>   ENTRY POSITIONS    <<<<<<<<<<<<<<<<<<
    //----------------------------------------------------------
    
    //  ---> LONG POSITIONS
    IF NOT LongOnMarket and ontime=1 THEN
    IF ConditionLong > 2 THEN
    stoplosslong= (close-S1)/pipsize+2*MetaRange/pipsize//in pips
    targetprofitlong=stoplosslong*Kprofit //in pips
    BUY 1 CONTRACTS AT MARKET
    SET STOP pLOSS stoplosslong
    SET TARGET pPROFIT targetprofitlong
    ENDIF
    ENDIF
    
    //  ---> SHORT POSITIONS
    IF NOT ShortOnMarket and ontime=1 THEN
    IF ConditionShort > 2 THEN
    StopLossShort=(Re1-close)/pipsize+2*MetaRange/pipsize // in pips
    targetprofitshort=StopLossShort*Kprofit // in pips
    SELLSHORT 1 CONTRACTS AT MARKET
    SET STOP pLOSS  StopLossShort
    SET TARGET pPROFIT targetprofitshort
    ENDIF
    ENDIF
    
    //---------------------------------------------------------
    //>>>>>>>>>>>>>>>>>>   EXIT POSITIONS    <<<<<<<<<<<<<<<<<<
    //---------------------------------------------------------
    If LongOnMarket THEN
    
    //////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE  ////////////////
    //If close > TRADEPRICE+targetprofitlong*pipsize THEN
    //SELL  AT MARKET
    //ENDIF
    //IF close  <  TRADEPRICE-stoplosslong*pipsize THEN
    //SELL  AT MARKET
    //ENDIF
    IF highest[BARINDEX-TRADEINDEX+1](high) > TRADEPRICE+0.75*stoplosslong*pipsize and (BARINDEX-TRADEINDEX)>=2 THEN
    Kexit=((TRADEPRICE+targetprofitlong*pipsize)-highest[BARINDEX-TRADEINDEX+1](high)) / ( (TRADEPRICE+targetprofitlong*pipsize) - (TRADEPRICE+0.75*stoplosslong*pipsize))
    IF low < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize and close < typicalprice  then
    SELL AT MARKET
    ELSIF close < highest[BARINDEX-TRADEINDEX+1](high)-Kexit*0.75*stoplosslong*pipsize THEN
    SELL AT MARKET
    ENDIF
    ENDIF
    
    ////////////////////////////
    
    IF CLOSE < S1[1] THEN
    SELL AT MARKET
    ENDIF
    
    IF high > TRADEPRICE + 0.75*stoplosslong*pipsize THEN
    SET STOP pLOSS 0.01
    ENDIF
    
    IF TIME > 214500 and DayOfWeek=5 then
    SELL AT MARKET
    ENDIF
    ENDIF
    
    // Bedingungen zum Ausstieg aus Short-Positionen
    IF ShortOnMarket THEN
    //////////////// UNTIL PARTIAL CLOSURE OF POSITION IS ACTIVE  ////////////////
    //IF close < TRADEPRICE-targetprofitshort*pipsize THEN
    //EXITSHORT AT MARKET
    //ENDIF
    //IF close > TRADEPRICE+stoplossshort*pipsize THEN
    //EXITSHORT AT MARKET
    //ENDIF
    IF lowest[BARINDEX-TRADEINDEX+1](low) < TRADEPRICE-0.75*stoplossshort*pipsize  and (BARINDEX-TRADEINDEX)>=2THEN
    Kexit=(lowest[BARINDEX-TRADEINDEX+1](low)-(TRADEPRICE-TargetProfitShort*pipsize) ) / ( (TRADEPRICE-0.75*stoplossshort*pipsize)-(TRADEPRICE-TargetProfitShort*pipsize))
    IF high > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize and close > typicalprice THEN
    EXITSHORT AT MARKET
    ELSIF close > lowest[BARINDEX-TRADEINDEX+1](low) + Kexit*0.75*stoplossshort*pipsize THEN
    EXITSHORT AT MARKET
    ENDIF
    ENDIF
    
    ////////////////////////////////
    
    IF CLOSE > Re1[1] THEN
    EXITSHORT AT MARKET
    ENDIF
    
    IF low < TRADEPRICE - 0.75*stoplossshort*pipsize THEN
    SET STOP pLOSS 0.01
    ENDIF
    
    IF TIME > 214500 and DayOfWeek=5 then
    EXITSHORT AT MARKET
    ENDIF
    
    ENDIF
    
    Screen-Shot-2019-01-28-at-22.40.29.png Screen-Shot-2019-01-28-at-22.40.29.png
    #89885 quote
    Vonasi
    Moderator
    Master

    I’ve had an RSI MTF strategy based on four time frames running on forward test on demo since the 22 August. Not many trades but profitable.

    [attachment file=89886]

    [attachment file=89887]

    …and this is the in sample that is still available for back test.

    [attachment file=89888]

    [attachment file=89891]

    The long only strategy has a simple daily market sentiment indicator that stops entry in major down markets. It enters if the fast RSI on all four time frames is below a certain level and exits if all four time frame RSI ‘s are over a certain level. It will also check once every 24 hours and if the trade is in profit it will also exit.

    There is some light money management in there but it is very light. I worry about the market sentiment filter being over optimized but otherwise it so far seems pretty robust. Very few trades to give confidence yet though.

    Screenshot_1-3.png Screenshot_1-3.png Screenshot_2-3.png Screenshot_2-3.png Screenshot_3-2.png Screenshot_3-2.png Screenshot_4-1.png Screenshot_4-1.png
    #89890 quote
    jebus89
    Participant
    Master

    I think mtf is going from 2d to 3d. theres infinite shit to do.. im going kinda crazy just thinking about it.

    Still havnt found a rly good way to take advantage just yet tbh, but i think it could help alot with the setup of the trade. Like saying “where the price has been before your entry” in multiple timeframes to better sort out at what “level” the price is on (high, low, mid range compared to X)

    #89893 quote
    jebus89
    Participant
    Master

    Looks sexy @Vonasi, could u share the “check if profitable every 24h and exit if profitable`” code?

    #89894 quote
    Vonasi
    Moderator
    Master

    The trouble with MTF is that as we bore down to faster time frames we lose data to test on. I go to bed at night dreaming of PRT offering me 35 years of data on all time frames. Sure back testing would be horrendously slow but I’d put up with that for the other benefits!

    #89895 quote
    Vonasi
    Moderator
    Master

    could u share the “check if profitable every 24h and exit if profitable`” code?

    No rocket science involved.

    timeframe (default)
    
    if not onmarket and (my conditions) then
    buy positionsize contracts at market
    tme = time
    endif
    
    if onmarket and close > positionprice  and time = tme then
    sell at market
    endif
    Midlanddave thanked this post
    #89896 quote
    jebus89
    Participant
    Master

    haha 35 years ye 😛

    Thanks for the code, any chance ur willing to share what ur “disaster filter” is here?

    “has a simple daily market sentiment indicator that stops entry in major down markets”

    Are we talking like a moving average or an actual indicator? Any chance ud share? my long only systems might want this lol

    #89897 quote
    Vonasi
    Moderator
    Master

    any chance ur willing to share what ur “disaster filter” is here?

    It is nothing special – just a look back to check that price is higher than it was a while back. Hence my concern that it is over fitted. As far as I am aware it has not been triggered yet in the forward test and wasn’t in the back test. It is just there to shut the strategy down in a big downturn. probably too late but better than nothing.

    I am still searching for the ‘holy grail’ market sentiment filter that fits multiple markets and have not found it yet despite sometimes thinking that I am close. This last year indices have done all they can to disprove all previous ideas and so proving that history does not repeat itself – well at least not when we want it to!

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

MultiTimeFrame simple conditions


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Leo @leito Participant
Summary

This topic contains 32 replies,
has 5 voices, and was last updated by jebus89
7 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 01/28/2019
Status: Active
Attachments: 11 files
Logo Logo
Loading...