Defining a time frame

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #86440 quote
    fxbravo
    Participant
    Average

    Hello gentlemen,

     

    I want to code this need, but I don’t know how to do it!

    My need: I take a simple RSI(14) but I want to check X time by day if the condition is OK or NotOK

     

    Here a drawto show you:

    9h00: the indicator check if the conditon is OK until 12h00 (it’s ok for this)

    14h00: the indicator check again if the condition is ok until 18h00/ It could be OK or NotOK, whatever it happen (OK or NotOK) between 9h/13h59 (like it’s the begining of the day, minus the timeframe 9h00/13h59)

     

    So, my problem is to “reset” à 14h00 the indicator

     

    Thank you for your help

     

    Have a perfect day

    #86444 quote
    Nicolas
    Keymaster
    Master

    It seems easy to reset a variable to 0 or whatever other value, so I don’t think that’s the main reason of your question? Do you still use the value “ok / not ok” of the morning period but in the afternoon? BTW, would be easier and faster to understand and reply with the code.

    #86446 quote
    fxbravo
    Participant
    Average

    Hello Nicolas,

     

    You’re right, it’s better with code 😉

    here an example of code I posted few days ago (the logic is the same):

    nb = intradaybarindex
     
    atrmax = highest[nb](AverageTrueRange[14](close))
    atrmin = lowest[nb](AverageTrueRange[14](close))
     
    middle = ABS((atrmax+atrmin)/2)
     
    return middle

    So, this morning, atrmax was 29 in UT1. So no pb for me, the market’spsychology is OK with that ATR. But, during lunch time, it’s not the same thing. And I wanted to “resest” the indicator with atrmax begining at 12h00, not 00h00.

     

    Hope that I explain this clearly 😉

     

    Thank you for your help Nicolas.

     

    Have a perfect day.

    #86449 quote
    fxbravo
    Participant
    Average

    If I could code this I’ll do:

    If time is between 00h00 and 12h00 then
    nb = intradaybarindex
     
    atrmax = highest[nb](AverageTrueRange[14](close))
    atrmin = lowest[nb](AverageTrueRange[14](close))
     
    middle = ABS((atrmax+atrmin)/2)
    
    enfif
    
    if the time is between 12h00 and 23h59 then
    
    nb = intradaybarindex (restart at 12h00)
     
    atrmax = highest[nb](AverageTrueRange[14](close))
    atrmin = lowest[nb](AverageTrueRange[14](close))
     
    middle = ABS((atrmax+atrmin)/2)
    
    enfif
     
    return middle

    So, if the value atrmax is X between 00h00 and 12h00, the code do the formula with X value.

    And if the  value atrmax is Y between 12h00 and 23h59, the code do the formula with Y value.

    #86454 quote
    Nicolas
    Keymaster
    Master

    This is what you need:

    if intradaybarindex=0 or time=120000 then 
    start=barindex
    endif
    
    nb=max(1,barindex-start)
     
    atrmax = highest[nb](AverageTrueRange[14](close))
    atrmin = lowest[nb](AverageTrueRange[14](close))
     
    middle = ABS((atrmax+atrmin)/2)
     
    return middle

    The period is a subtraction between the current barindex and the one saved when you want the period of calculation to start, at the beginning of the day or at 120000.

    #86461 quote
    fxbravo
    Participant
    Average

    Thank you Nicolas for your quick and perfect answer.

     

    Have a perfet day.

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

Defining a time frame


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
fxbravo @fxbravo Participant
Summary

This topic contains 5 replies,
has 2 voices, and was last updated by fxbravo
7 years, 3 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 12/06/2018
Status: Active
Attachments: No files
Logo Logo
Loading...