Why does my indicator not work for currency?

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #224135 quote
    edktrading
    Participant
    New

    Hi,

    I tried to create an indicator to show a yellow rectangle around some hours of the new york session.

    i did some copy pasting from other codes, because i am new to coding. see the attatched code.

    My problem, the code works fine for ES/MES , indexes.

    But i want is also to work for currancypairs, like EURUSD, etc.

    Can anyone tell me why it is not working?

    starttime = 140000
    endtime = 170000
    
    
    if time = starttime then
    startbar = barindex
    endif
    if time = endtime then
    endbar = barindex
    endif
    
    if time >= starttime and time <= endtime then
    if high > hh then
    hh = high
    endif
    if low < ll or ll = 0 then
    ll = low
    endif
    endif
    
    hh = round(hh)
    ll = round(ll)
    
    if intradaybarindex = 0 then
    hh = 0
    ll = 0
    endif
    
    if time > endtime then
    DrawRectangle(startbar,hh,endbar,ll) coloured("Yellow",25) BorderColor("Yellow",25) 
    endif
    
    return
    
    #224139 quote
    JC_Bywan
    Moderator
    Master

    Hi,

    delete both lines with “round”: lines 21 and 22

    Using “round()” brings you to the closest integer. On an index quoting in thousands, rounding it doesn’t change its value a lot, but on a currency where pips are in decimals… for example EURUSD, an hh at 1.09613 when rounded would become = 1 and rounding ll = 1.09314 would make it = 1 too… so that’s a flat rectangle located at 1, which is why you couln’t see anything.

    Code will work without these 2 lines.

    edktrading thanked this post
    #224140 quote
    edktrading
    Participant
    New

    Thanks a lot, you are my hero! 😉

    #224431 quote
    edktrading
    Participant
    New

    Can someone help me with the following please: is it possible to see the rectancle during the session?

    Now you only see the rectangle in hindsight.

    I know it has to do with “if time > endtime then” but i tried different this, but no results….

    Thanks in advance!

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

Why does my indicator not work for currency?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
edktrading @edktrading Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/22/2023
Status: Active
Attachments: 1 files
Logo Logo
Loading...