How to know last bar on the chart

Forums ProRealTime English forum ProBuilder support How to know last bar on the chart

Viewing 4 posts - 1 through 4 (of 4 total)
  • #56751

    Hi,

    I’m starting coding with PRC and I have some problems with the following:

    To know if the last bar on the chart (most right one) I use the following code:  ===>>    If date=Today then

    This works perfect for daily charts but dosn’t work for weekly and/or monthly charts.

    So how can I determine when I reach the last bar on the chart (most right one, current week or month)

    Thnx

     

     

    #56760

    You can get a code snippet in this thread: How to know EOF? the last barindex?

    It returns true if the current bar is the last known one.

    #56764

    Nicolas,

    LastBarOnChart=currenttime=opentime and date=today 

    ==> doesn’t work like I need it.

    I enclose the programming, it is the Swing Counter Indicator. I think you wrote it, I modified it a litle.µ

    This code works fine with daily charts, it doesn’t work with charts on weekly or monthly basis.

    How can I make it work for whatever period I use (fi week – month)

     

    #56813

    Hi,

    With try and error I found out the following:

    I replaced ==> LastBarOnChart=date=today

    with ==> Daylastbar=date=today                                     //true if last bar on daychart is today – most right one on the chart
    Weeklastbar=date-dayofweek+1=today        //true if last bar on weekchart is this week – most right one on the chart
    Monthlastbar=date-day+1=today                   //true if last bar on monthchart is this month- most right one on the chart

    And used these variables in the “if” conditions. => Are these calculations, to check if the most right bar in the day, week or month chart is the last one available (EOF) and therefore Today, correct??

    So the code becomes as follows:

     

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

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