Multi-timeframe Trading

Forums ProRealTime English forum ProOrder support Multi-timeframe Trading

Viewing 3 posts - 1 through 3 (of 3 total)
  • #252315

    Hi everyone,

    I have looked at Nicolas’ post on multi- timeframe indicators but I’m still unsure as to the general format of how to apply this to several timeframes for strategies.

    I’m using 4 timeframes, a 1 hour, 15 minute, 30 second and 1 second timeframes.

    I need to write the follow kind of condition:

    IF ‘condition A’ appears on 1 hour chart AND ‘condition B’ appears on 15 minute chart AND ‘condition C’ appears on 30 second chart AND ‘condition’ D appears on 1 second chart then BUY(x)CONTRACTS. EXIT IF ‘condition E’ appears on 1 second chart.

    Many thanks in advance.

    #252317

    Hi,

    I’ll tell you the general format, but first, you need to take into account the maximum history applies to the smallest timeframe, and the initial amount of candles available prior to start point is 10000. So if you need more candles than this, your code wouldn’t take any trade until data “exists” in the biggest timeframe. In backtest on a very long history, you might see some trades, but trading real time you might have to wait for a very long time before history beyond the preloaded 10000 becomes enough if you need more than these 10000.

    So, how to work out how many candles you need in smallest timeframe? Take amount of candles for all your data to exist in biggest timeframe (for example, let’s say the longest constraint is a 200 candles moving average, take 200 times 4h =800), and multiply it either by what it takes to reach your smallest timeframe wanted, or, work your way down timeframe by timeframe and stop if going beyond 10000 to know which smaller timeframes are available to you for your code to be working live at launch instead of waiting for more candles to occur after launch. Keeping the example, 800 in 4h, times 4 gives 3200 candles in 1h, and in 15mn you’d already be at 4×3200=12800 beyond the max preloaded of 10000, so would have to wait in real time after launch for 2800 15mn candles before data in 4h exists (and a bit more if 4h candle is not closed yet and you want data on 4h close) and code can work with 15mn as the small timeframe… Anything smaller is even more candles to wait for beyond the max preloaded 10000 candles and it becomes quickly unrealistic.

    You get the idea, it means you need to make sure your biggest and smallest timeframe are not too far apart. Either its a non-starter for your setup, or you have to get rid of timeframes at one end of the spectrum (or on each side). And it all depends on how many candles are needed in the biggest one you select.

    Format would be:

    defparam preloadbars=10000

    timeframe(4h)

    conditionA=…

    timeframe(1h)

    conditionB=…

    etc…

    timeframe(default)//the timeframe the code operates in

    if conditionA AND conditionB AND … then

    buy x contracts at market

    endif

    Exitcondition=…

    If Exitcondition then

    sell at market

    endif

     

    3 users thanked author for this post.
    #252340

    Thank you so much for such a thoughtful and detailed reply JC_Bywan.

Viewing 3 posts - 1 through 3 (of 3 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login