Simple bar counter wanted.

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #261570 quote
    Alex Hanczarski
    Participant
    New

    Does anyone have a bar counter program available for PRT v12 for mac? Many thanks Alex.

    #261572 quote
    Iván González
    Moderator
    Legend

    Hello. Do you mean this?

    return barindex
    

    Or perhaps for intraday data you’d like this

    return intradaybarindex
    
    #261574 quote
    Alex Hanczarski
    Participant
    New

    Hi Ivan,

    Not sure yet, I am new to this forum so I haven’t learned where the files go when I click copy … I will keep searching, Many thanks.

    #261575 quote
    Nicolas
    Keymaster
    Legend

    When you click “copy” the code goes into your clipboard on your computer, then just paste it into the indicator code editor available in the platform.

    What do you mean about a bar counter? The total amount of bars available on the chart? Or maybe a bar timer? Let’s describe it, so we’ll point you onto the right direction 🙂

    #261578 quote
    Alex Hanczarski
    Participant
    New

    What I want to do is: I set a start time, 8:00 am for Europe, 2:30pm US open, Then set a time to stop the count. It will then count the first 8:00am bar as No 1, next candle No 2 until the stop time 8 hours later. Will not matter what timeframe I use. So a very simple bar counter. I have tried a search but nothing so far. Thanks again.

    #261579 quote
    Nicolas
    Keymaster
    Legend

    Where do you want to see the bars count? On each bar directly? With a text anchored in a corner of the chart? Below the chart as an histogram or a curve? Let us know! 😉

    #261582 quote
    Alex Hanczarski
    Participant
    New

    I have attached the bar counter view I get with the TradigView platform. I would like the bars to be numbered on PRT v12 exactly the same as the screenshot. Thank you for your patience

    #261587 quote
    Alex Hanczarski
    Participant
    New

    I will try to attach the screenshot again …

    Screenshot-2026-05-28-at-1.34.42-pm.png Screenshot-2026-05-28-at-1.34.42-pm.png
    #261588 quote
    Iván González
    Moderator
    Legend

    Let’s see if this helps.

    startTime = 080000   // (HHMMSS)
    endTime   = 160000
    
    if gettimeframe < 86400 then
       if opentime >= startTime and opentime <= endTime then
          if n[1] = 0 then
             n = 1
          else
             n = n[1] + 1
          endif
          
          drawtext("#n#", barindex, low - 0.5*averagetruerange[14](close)) coloured("black")
          
       else
          n = 0
       endif
    else
       n = 0
    endif
    return
    

    I had I mistake in my code. now it’s ok


    robertogozzi thanked this post
    #261590 quote
    Alex Hanczarski
    Participant
    New

    I will need to study your reply later, as its all a bit over my head at the moment. Thanks again.

    #261592 quote
    Nicolas
    Keymaster
    Legend

    Maybe this version:

    startTime = 080000
    endTime   = 190000
    
    
    IF TIME >= startTime AND TIME <= endTime THEN
        IF TIME[1] < startTime OR TIME[1] > endTime THEN
            n = 1
        ELSE
            n = n[1] + 1
        ENDIF
        DRAWTEXT("#n#", barindex, low - 0.5 * AVERAGETRUERANGE[14](close)) COLOURED(0, 0, 0, 255)
    ELSE
        n = 0
    ENDIF
    
    
    RETURN
    
    robertogozzi thanked this post
Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.

Simple bar counter wanted.


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 10 replies,
has 3 voices, and was last updated by Nicolas
1 day, 5 hours ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 05/28/2026
Status: Active
Attachments: 1 files
Logo Logo
Loading...