How to get current TimeFrame inside indicator code?

Forums ProRealTime English forum ProBuilder support How to get current TimeFrame inside indicator code?

Viewing 7 posts - 1 through 7 (of 7 total)
  • #31811

    Hi,

    How can my indicator automatically know about current time frame for the chart (like daily, 4hrs, 1hr, 15min, 5min etc)?

     

    #31871

    This code snippet can return the current timeframe information as a value in minutes: (not from me, came from a topic on the French forum if I remember correctly)

     

    #31882

    Perfect thanks!!!

    #41604
    AVT

    Would anyone be so kind to explain what the code just 2 posts above is doing? I am completely lost on understanding it.

    It begins already with the if statement: BarIndex will never/seldom be less than 3 (at least on my computer I see only values around 500 minimum) , so the caculation should never be executed!

    I tested all the times I can load with that code, for 4 hours it gives Timeframe=1.500 although the abs(barminutes) is correct 240 and for 7 hours Timeframe=180 with abs(barminutes)=420.

    I need to limit calculation in one of my scripts depending on the timeframe of the chart and usually I am of the opinion “one must not invent the wheel for the 101st time”, but I don’t like to just c&p code hoping it will work without understanding it. That’s the code from above:

    Thanks a lot.

    #41606

    Why

    is not written as

    ?

    Because NbBar NEVER changes!

    1 user thanked author for this post.
    avatar AVT
    #41658
    AVT

    @robertogozzi

    Thanks for your answer. It gave me indirectly the first solution (the if statement says simply: only take the first two bars for caculation) – sometimes I am a blockhead!

    You said NbBar never changes – 2 also never changes, so consequently NbBar+2 will ALWAYS be 3 and it is legitimate to write

    NbBar is only used once agin in that code, in the line

    and as it never changes and in the meantime its value has not been changed (by looping or something like that), it is as well legitimate to write

    and NbBar=1 is not needed any longer. Correct?

    Thank you so much.

    #41678

    Correct!

    Roberto

    1 user thanked author for this post.
    avatar AVT
Viewing 7 posts - 1 through 7 (of 7 total)

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