Enter a trade based on multiple timeframes 1min/5min

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #188654 quote
    RichardVeen
    Participant
    Junior

    Hi,

    I want start a trade by using mulitple timeframes.

    For example: I want to start a trade in the 1m chart based on the close in the 1min chart and  the highs/lows of the 5min chart.

    I don’t know how to create a code using multiple timeframes so I created the code below but I don’t have any result after backtesting, what is wrong?

    Or does anybody have a idea how to create the code with multiple timeframes?

    Thanks in advance.

    bars5 = 5
    Y1 = highest[bars5]
    X1 = lowest[bars5]
    
    c1 = close>close[1]
     
    if c1 and close>Y1 then
    Buy possize contract at Market
    endif
     
    c2 = close<close[1]
     
    if c2 and close<X1 then
    Sellshort possize contract at Market
    endif
    #188667 quote
    robertogozzi
    Moderator
    Master

    To learn how to use multiple time frames in your code, you should search this forum for the word MTF. You’ll be returned many articles, posts and code snippets to learn from.

    This is your code as requested (not tested):

    Timeframe(5 minute,UpdateOnClose)      //or Timeframe(5 minute,default) not to wait the 5-minute closing
    Y1 = high
    X1 = low
    //
    Tomeframe(1 minute,UpdateOnClose)      //or Timeframe(1 minute,default) not to wait the 1-minute closing
    c1 = close>close[1]
    c2 = close<close[1]
    //
    Timeframe(default)                     //this the TF on your chart, it cannot be higher than the lowest TF used in your code (1 minute in your case)
    if c1 and close>Y1 then
       Buy possize contract at Market
    endif
    if c2 and close<X1 then
       Sellshort possize contract at Market
    endif
    #188795 quote
    RichardVeen
    Participant
    Junior

    Hi @robertogozzi,

    It’s working!

    Thanks again!

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

Enter a trade based on multiple timeframes 1min/5min


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by RichardVeen
3 years, 12 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/22/2022
Status: Active
Attachments: No files
Logo Logo
Loading...