Draw a rectangle each day between 00:00 and 07:00

Forums ProRealTime English forum ProBuilder support Draw a rectangle each day between 00:00 and 07:00

Viewing 9 posts - 1 through 9 (of 9 total)
  • #22207

    Good evening,

    I am new to ProRealCode and would like to understand where I am wrong.

    I need to draw a rectangle each day from 00:00 to 07:00  where Y1/Y2 are low/high for the same time frame.

    If I uncomment line 1 (defparam drawonlastbaronly=true) it works fine on last day.

    Uncommenting this line causes the rectangle to be drawn for all periods and I don’t realise why.

    Any help is really appreciated.

    Thanks

    Giovanni

    PS I attach screenshot of the actual wrong visualisation.

     

     

     

     

     

    #22234

    In fact this is not a problem, because your result give you exactly what you have coded.

    If you don’t use the ‘drawonlastbaronly’ function, the code is read and executed while the history is read at the first time. As you may already know, prorealtime only read once the history and drawn things on chart can’t be erased.

    So, in order to draw correctly the rectangles in your chart history, you’ll need to begin and end drawing them, once the last schedule (X coordinates = barindex) has already passed.

    Another possibility could be to use the ‘drawonlastbaronly’ and make loop through the past data, but it would be memory consuming for the platform.

    But if I understand correctly what you want to achieve here, is to draw the current rectangle (the one for the current day) and the ones from previous day also?

    #22423

    Thank you Nicolas,

    I amended  the code as you explained  and now it’s working fine .

    The only issue is that it worked after restarting my PC, without changing any line of code at all.

    I then tried to add a background to the rectangle but there is no way to do it, as far as I know.

    Thank you Nicolas!

     

     

     

    #66741

    i wanted to change this box to 4am to 7am i tried below,

    but it didnt do anything any reason why???

    #66753

    It’s because line 9 will never be true after 000000.

    Insert a new line between 3 and 4 which reads

    then at line 9 (now line 10) replace intradaybarindex with MyBar

    and, finally, insert a line before or after line 10 (now line 11)

     

     

     

    #66754

    @crolakstrading

    There was an ENDIF wrongly placed in the code. The X1 coordinate was not correctly found, here is the code fixed:

     

    #66756

    Well Nicolas, that would partially do, you’ll have a rectangle displayed also for hours BEFORE 040000.

    I think the problem was the one I posted about.

     

    #66757

    To recap :

     

    #67036

    Thank you both! @robertogozzi & @Nicolas

Viewing 9 posts - 1 through 9 (of 9 total)

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