Multiple Timeframes in an indicator

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #245472 quote
    SkySurferBlue
    Participant
    New

    Hi

    Is it possible to have a higher timeframe moving average like the 4hr which then determines the value of a variable “Startime”

    Then use “Startime” in your lower timeframe like 5min.

    It gives me a parsing error when I then call the indicator function into my trading strategy.

    Timeframe(4hour,updateonclose)
    If Close<exponentialaverage[20]*0.985 Then
    Startime=090000
    else
    Startime=101500
    endif

    Timeframe(Default,updateonclose)
    If Time > Startime and Time < 133000 Then
    If Openhour > 9 and Close/Close[190]-1 > 1.25/100 Then
    TradeLong=0
    else
    TradeLong=1
    Endif
    If Openhour > 9 and Close/Close[190]-1 < -0.9/100 Then
    TradeShort=0
    else
    TradeShort=1
    Endif
    Endif

    #245474 quote
    druby
    Participant
    New

    If the ‘call’ed indicator has the timeframe command in it, I think that causes the parse error.

    Its best to write the code directly in the strategy file, this avoids the longer execution times with the calling process.

    However, it can  work  if the TIMEFRAME command is in the strategy file and the call is from the timeframe block, but it will be longer to execute.

    Also the indicator file has to be suitably set up as a general indicator which works with any timeframe its put on.

    Keeping the execution time down , helps when back-testing.

    ivanPrt and robertogozzi thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Multiple Timeframes in an indicator


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by druby
11 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 03/31/2025
Status: Active
Attachments: No files
Logo Logo
Loading...