How to avoid drawing on the current bar ?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #195024 quote
    PeterSt
    Participant
    Master

    Hi All,

    Does someone know the trick which avoids drawing on the last bar ? It should be very easy, but I can’t find anything (also tried stuff around IsLastBarUpdate).

    You see me drawing minutes above the bars. But the current (rightmost) bar repeats the minute of the previous bar (see the “08”). And, if I would be able to add an extra minute/count to that current bar, it would also be fine (even better; I want to show it correctly – or show nothing if it’s wrong).

    Thanks !
    Peter

    #195052 quote
    Nicolas
    Keymaster
    Master

    Please post the code so I can get a better picture of what you want to be plotted or not.

    #195114 quote
    PeterSt
    Participant
    Master
    // Apply to 1 minute Chharts.
    
    //DefParam DrawOnLastBarOnly = true
    DefParam CalculateOnLastBars = 1500
    
    
    MyMinute = Minute - 1   // Because we need correction.
    If MyMinute = -1 then
      MyMinute = 59
    endif
    
    Once VerticalOffset = 0   // Would like a pixel offset here. ;-)
    
    Once LastBarWritten = BarIndex
    
    //If LastBarWritten <> BarIndex + 1 then
    
    If MyMinute = MyMinute[1] then   // This seems to work ?
      MyMinuteReal = MyMinute + 1
    else
      MyMinuteReal = MyMinute
    endif
    
    DrawText (MyMinuteReal, barindex, high + VerticalOffset * 2, SansSerif, standard, 11)
    
    //endif
    
    LastBarWritten = BarIndex
    
    Dummy = close
    Return dummy
    

    During the posting of this, I suddenly saw the light (??). This is in a static environment because markets are closed at this moment. So must check later today on a live market whether this works out for real (it could matter).

    #195118 quote
    robertogozzi
    Moderator
    Master

    Replace line 24 with:

    DrawText (MyMinuteReal[1], barindex-1, high[1] + VerticalOffset * 2, SansSerif, standard, 11)
    #195124 quote
    PeterSt
    Participant
    Master

    Yes, thanks. I had that version too by means of a similar If as that I already use, around the DrawText. That (and yours) omits the drawing on the current bar. This is great for certain applications.

    The one I showed indeed now works too and that is drawing the correct minute on the current bar, also when the market is live.

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

How to avoid drawing on the current bar ?


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
PeterSt @peterst Participant
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by PeterSt
3 years, 8 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 06/10/2022
Status: Active
Attachments: 3 files
Logo Logo
Loading...