TheStrat – full tf continuity

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #206600 quote
    ullle73
    Participant
    Senior

    Im looking to create my own system thats based on TheStrat and “full timeframe continuity” meaning, the more TF that are in the same directions, the better. Pure priceaction system that seems very popular.

    If anyone could help me code the following:

    • Timeframes: 1m, 5m, 15m, 30m, 1h, 4h, Daily, Weekly, Monthly (would love to have an option to turn on/off every single TF, to be able to backtest different combos of TF) if not possible, use Monthly, Weekly, Daily and 1h
    • When selected TF have the same candle color, go long/short
    • SL: x, TP: y
    • Optional trendfilter, above/below ma200 on daily (prefered to code a turn on/off option)
    • If possible to use this MM system below: (prefered to code a turn on/off option for MM) else standard size 1 lot
    • Time filter, trade only between 090000 and 173000
    once os      = 1   //ordersize - can be any number depending on account size.
    once osa     = os
    once kax     = 15  //15
    once teilung = 2   //1.5 reducing the ordersize after winning trade
    //once zl=2  // 2 Ziellevel. Quadrant wird in zl Teile geteilt, je weniger, desto höher das Ziel
    //once mgr=60  // 40  Mindestgröße des Channels
    once ff      = twice   //2.5 increasing ordersize after losing trade. (for first 2 consecutive losses)
    once ff2     = third   //1.2 times the size after the THIRD consecutive LOSS
    once ff3     = fourth   //1.4 times the size after the FOURTH consecutive LOSS
    once ff4     = fifth   //1.7 times the size after the FIFTH consecutive LOSS  (beyond 5 losses, stop increasing)
    once maxcon  = 50// defing the maximum ordersize
    once losses  = 0
    
    if strategyprofit>sp then  // and if equity reaches maximum again.
    os = osa
    sp = strategyprofit
    endif
    start=0
    endif
    
    
    if strategyprofit<strategyprofit[1] then // increasing ordersize when losing
    losses = losses + 1
    IF losses <= 2 then
    os = os * ff
    elsif losses = 3 then
    os = os * ff2
    elsif losses = 4 then
    os = os * ff3
    elsif losses = 5 then
    os = os * ff4
    endif
    //if os>maxcon then
    //os=maxcon
    //endif
    os = min(os,maxcon)
    endif
    start = 1
    endif
    
    if strategyprofit>strategyprofit[1] then // decreasing ordersize when winning
    losses = 0
    start  = 1
    os     = 1 //teilung
    //if os<osa then
    //os=osa
    //endif
    os    = max(osa,os)
    endif
    
    #206612 quote
    robertogozzi
    Moderator
    Master

    You can use at most 6 different TFs in your code, so in your case you will have to drop 3 of those you mentionned, then duplicate the strategy and replace three TFs with the missing ones.

    I’ll code it asap.

    Which are the prefered 6 timeframes you want to start with?

    ullle73 thanked this post
    #206621 quote
    ullle73
    Participant
    Senior

    wow, thanks roberto!!! 😀

     

    go with monthly, weekly, daily, 1h, 15m and 5m

    #206720 quote
    robertogozzi
    Moderator
    Master

    There you go:

    DEFPARAM CumulateOrders = False
    //
    Timeframe(Monthly,UpdateOnClose)
    BullishM   = close > open
    BearishM   = close < open
    //
    Timeframe(Weekly,UpdateOnClose)
    BullishW   = close > open
    BearishW   = close < open
    //
    Timeframe(Daily,UpdateOnClose)
    BullishD   = close > open
    BearishD   = close < open
    ma200      = average[200,0](close)
    //
    Timeframe(1h,UpdateOnClose)
    Bullish1H  = close > open
    Bearish1H  = close < open
    //
    Timeframe(15mn,UpdateOnClose)
    Bullish15  = close > open
    Bearish15  = close < open
    //
    Timeframe(5mn,UpdateOnClose)
    Bullish5   = close > open
    Bearish5   = close < open
    //
    Timeframe(default)
    //
    TimeCond   = time >= 090000 AND time <= 173000
    //
    // replace OR 0 with OR 1 to disable one or more conditions
    //
    LongCond   = TimeCond                    OR 0
    LongCond   = LongCond  AND BullishM      OR 0
    LongCond   = LongCond  AND BullishW      OR 0
    LongCond   = LongCond  AND BullishD      OR 0
    LongCond   = LongCond  AND Bullish1H     OR 0
    LongCond   = LongCond  AND Bullish15     OR 0
    LongCond   = LongCond  AND Bullish5      OR 0
    LongCond   = LongCond  AND close > ma200 OR 0
    //
    ShortCond  = TimeCond                    OR 0
    ShortCond  = ShortCond AND BearishM      OR 0
    ShortCond  = ShortCond AND BearishW      OR 0
    ShortCond  = ShortCond AND BearishD      OR 0
    ShortCond  = ShortCond AND Bearish1H     OR 0
    ShortCond  = ShortCond AND Bearish15     OR 0
    ShortCond  = ShortCond AND Bearish5      OR 0
    ShortCond  = ShortCond AND close < ma200 OR 0
    //
    ONCE SL    = 20
    ONCE TP    = SL * 6
    //
    once os      = 1   //ordersize - can be any number depending on account size.
    once osa     = os
    once kax     = 15  //15
    once teilung = 2   //1.5 reducing the ordersize after winning trade
    //once zl=2  // 2 Ziellevel. Quadrant wird in zl Teile geteilt, je weniger, desto höher das Ziel
    //once mgr=60  // 40  Mindestgröße des Channels
    once ff      = 2.5//twice    //2.5 increasing ordersize after losing trade. (for first 2 consecutive losses)
    once ff2     = 1.2//third    //1.2 times the size after the THIRD consecutive LOSS
    once ff3     = 1.4//fourth   //1.4 times the size after the FOURTH consecutive LOSS
    once ff4     = 1.7//fifth    //1.7 times the size after the FIFTH consecutive LOSS  (beyond 5 losses, stop increasing)
    once maxcon  = 50// defing the maximum ordersize
    once losses  = 0
    
    if strategyprofit>sp then  // and if equity reaches maximum again.
    os = osa
    sp = strategyprofit
    endif
    start=0
    
    if strategyprofit<strategyprofit[1] then // increasing ordersize when losing
    losses = losses + 1
    IF losses <= 2 then
    os = os * ff
    elsif losses = 3 then
    os = os * ff2
    elsif losses = 4 then
    os = os * ff3
    elsif losses = 5 then
    os = os * ff4
    endif
    //if os>maxcon then
    //os=maxcon
    //endif
    os = min(os,maxcon)
    endif
    start = 1
    if strategyprofit>strategyprofit[1] then // decreasing ordersize when winning
    losses = 0
    start  = 1
    os     = 1 //teilung
    //if os<osa then
    //os=osa
    //endif
    os    = max(osa,os)
    endif
    //
    IF LongCond  AND Not OnMarket THEN     //use    Not LongOnMarket  to Stop & Reverse
    BUY os CONTRACTS AT MARKET
    ENDIF
    IF ShortCond AND Not OnMarket THEN     //use    Not ShortOnMarket to Stop & Reverse
    SELLSHORT os CONTRACTS AT MARKET
    ENDIF
    //
    SET STOP   pLOSS   SL
    SET TARGET pPROFIT TP
    MySystem.itf
    #206737 quote
    ullle73
    Participant
    Senior

    Wow, perfect Roberto! thanks alot! 😀

     

    Could i ask for you to add two different entry criterias? option to activate or deactivate like you did with the different timeframs.

    Entry #1: when the lowest TF cross over/under ema5

    Entry #2: when rsi3 cross over 30/under 70

    #206765 quote
    robertogozzi
    Moderator
    Master

    Timeframes cannot be used with options to enable/disable them. You have two choices:

    • disable the timeframe by adding two leading backslashes on that line
    • changing the value of the timeframe (say change DAILY to 4H, still leaving variables unchanged if you prefer).

    Entry #1 and #2 are to be both met on the lowest TF?

    The two new conditions are to be added or shall they replace the existing Bullish/Bearish condition?

    ullle73 thanked this post
    #206802 quote
    ullle73
    Participant
    Senior

    i see, but i can set 1 on long cond (line 36) to disable weekly bias right?

     

    when Monthly, Weekly, Daily, 1h, m15 and m5 are green, buy when rsi3 cross above 30 or price cross above ema5 on m5 TF

    reverse for shorts. 70 level for short on rsi.

     

    thanks roberto!!

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

TheStrat – full tf continuity


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
ullle73 @jonas_rydqvist Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by ullle73
3 years, 1 month ago.

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