Conversion of “Bar Count by GYH9” from the TradingView software

Forums ProRealTime English forum ProBuilder support Conversion of “Bar Count by GYH9” from the TradingView software

Viewing 15 posts - 1 through 15 (of 19 total)
  • #205841

    Hello! Thank you for taking time to read this. I have found a code on TradingView that assigns a number to every other bar in the session. This allows me to reference bars, for example “bar 24 made a higher high” etc. I am wondering if this code can be converted to the ProRealTime software. All it should do is put a tiny number below every other bar in the session (I use regular trading hours).
    If this is possible to convert, I will be forever thankful! Regards, Andreas Faurholdt.

    This is the TradingView code: (it is also attached)

     

    //@version=4
    study(“Bar Count”, overlay=true, max_labels_count=500)
    sizeOption = input(title=”Label Size”, type=input.string,
         options=[“Auto”, “Huge”, “Large”, “Normal”, “Small”, “Tiny”],
         defval=”Normal”)
    labelSize = (sizeOption == “Huge”) ? size.huge :
         (sizeOption == “Large”) ? size.large :
         (sizeOption == “Small”) ? size.small :
         (sizeOption == “Tiny”) ? size.tiny :
         (sizeOption == “Auto”) ? size.auto :
             size.normal
    color c_labelColor = input(color.orange, “Text Color”, input.color)
    c_contador = input(title=”Display at every X bars”, type=input.integer, defval=2)
    is_new_day()=>
        d=dayofweek
        na(d[1]) or d != d[1]
    var count = 1
    if is_new_day()
        count := 1
    else
        count := count + 1
    if count % c_contador == 0
        label1 = label.new(bar_index, 0, style=label.style_none, text=tostring(count))
        label.set_textcolor(label1, c_labelColor)
        label.set_yloc(label1, yloc.belowbar)
        label.set_size(label1, labelSize)
    #205849
    JS

    Hi @gadetrading

    Here is the indicator…

    You can adjust the session times…

     

    2 users thanked author for this post.
    #205875

    Hello JS.

    Thank you. It is greatly appreciated.

    If possible I have an additional request:
    Can you make the bar count reset at the start of every session? I have set custom trading hours to show data from 09:00 to 17:30 for the German DAX index and ideally I want the counting to begin from 09:00 and end at 17:30 and then the count will reset the next day and start over at 09:00. I have multiple days shown on my chart and the numbers get very big right now.

    #205881
    #205886

    Just change the “endsession” setting with the desired time. Peter has set it with 220000 (10pm).

    1 user thanked author for this post.
    #205891
    JS

    Hi @gadetrading

    You just need to adjust the session times…

    For the DAX:

    StartSession=090000

    EndSession=173000

    1 user thanked author for this post.
    #205892

    @Nicolas @JS
    I have set the desired time, however, it does not start over (reset the bar count) every time the clock is 9 AM. I have shown it in the screenshot, for example, bar 614 should be bar 2 since it is the second bar after 9 AM.

    #205895
    JS

    Hi @gadetrading

    I think you’ve set the trading hours separately in “Time Zones & Trading Hours”…

    Maybe it helps if you set it to 08:55 to 17:35

    Time frame 5 minutes.

    #205896

    Please don’t embed pictures in content, it is not necessary.

    I think end session should use Time instead of OpenTime, what do you think @JS ?

    1 user thanked author for this post.
    #205897
    JS

    Hi @Nicolas

    The indicator does what it is supposed to do here, also on the DAX…

    I think it’s the settings in the “Time Zones & Trading Hours”

    #205907

    Hello @JS
    Thank you.
    I have set the settings in “Time Zones & Trading Hours” to show only regular trading hours for the DAX CFD. I have also tested the bar count indicator as you requested with 08:55 and 17:35 which fixes the problem and the counting resets at 09:00 every day. However, I do not wish to show those two extra bars on my 5 minute chart. I only wish to show price action from 09:00 to 17:30 for the CFD and still have the count reset at 09:00 every day.

    #205908
    JS

    Hi @gadetrading

    Try Nicolas’ solution:

    Change “OpenTme = EndSession ” to  “Time = EndSession”

    1 user thanked author for this post.
    #205909

    @JS @Nicolas
    Now I understand. Nicolas’ solution works. It is now functioning like I want it to with “Time = EndSession”.
    Thank you both for taking the time to help. It is appreciated.

    1 user thanked author for this post.
    avatar JS
    #210090

    Hello @JS
    Is it possible to make sure the bar counter resets every day?

    I have attached a screenshot. This is a problem because some days have less bars than others in the same timespan.
    In the screenshot you can see that the first bar of the day is actually bar 67, when it should be bar 1. It is because yesterday had fewer bars than other days in the same timespan.

    #210095
    JS

    Hi gadetrading,

    You can try/add this…

    If IntraDayBarIndex = 0 then

    Count = 0

    EndIf

    1 user thanked author for this post.
Viewing 15 posts - 1 through 15 (of 19 total)

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