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
- This topic has 18 replies, 3 voices, and was last updated 1 year ago by gadetrading.
-
-
12/15/2022 at 8:59 PM #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=4study(“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.normalcolor 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=dayofweekna(d[1]) or d != d[1]var count = 1if is_new_day()count := 1elsecount := count + 1if count % c_contador == 0label1 = 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)12/15/2022 at 11:48 PM #205849Hi @gadetrading
Here is the indicator…
You can adjust the session times…
Even Bar Count123456789101112131415161718Once Count = 0StartSession=153000EndSession=220000If OpenTime >= StartSession and OpenTime <= EndSession thenCount=Count+1xEven=Count/2 - Round(Count/2)If Count > 0 and xEven=0 thenDrawText( "#Count#", BarIndex,Low-10*pipsize)EndIfIf OpenTime = EndSession thenCount=0EndIfEndIfReturn2 users thanked author for this post.
12/16/2022 at 11:31 AM #205875Hello 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.12/16/2022 at 11:45 AM #20588112/16/2022 at 1:06 PM #205886Just change the “endsession” setting with the desired time. Peter has set it with 220000 (10pm).
1 user thanked author for this post.
12/16/2022 at 1:35 PM #205891Hi @gadetrading
You just need to adjust the session times…
For the DAX:
StartSession=090000
EndSession=173000
1 user thanked author for this post.
12/16/2022 at 1:36 PM #20589212/16/2022 at 1:49 PM #205895Hi @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.
12/16/2022 at 1:55 PM #205896Please 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.
12/16/2022 at 2:17 PM #20589712/16/2022 at 2:28 PM #205907Hello @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.12/16/2022 at 2:43 PM #205908Hi @gadetrading
Try Nicolas’ solution:
Change “OpenTme = EndSession ” to “Time = EndSession”
Even Bar Count V2123456789101112131415161718Once Count = 0StartSession=090000EndSession=173000If OpenTime >= StartSession and OpenTime <= EndSession thenCount=Count+1xEven=Count/2 - Round(Count/2)If Count > 0 and xEven=0 thenDrawText( "#Count#", BarIndex,Low-10*pipsize)EndIfIf Time = EndSession thenCount=0EndIfEndIfReturn1 user thanked author for this post.
12/16/2022 at 2:48 PM #20590902/21/2023 at 7:13 PM #210090Hello @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.123456789101112131415161718Once Count = 0StartSession=093000EndSession=161500If OpenTime >= StartSession and OpenTime <= EndSession thenCount=Count+1xEven=Count/2 - Round(Count/2)If Count > 0 and xEven=0 thenDrawText( "#Count#", BarIndex,Low-2*pipsize,SansSerif) COLOURED (153, 153, 153, 255)EndIfIf Time = EndSession thenCount=0EndIfEndifReturn02/21/2023 at 8:18 PM #210095Hi gadetrading,
You can try/add this…
If IntraDayBarIndex = 0 then
Count = 0
EndIf
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on