Bar Counter Display Current Day Only
Forums › ProRealTime English forum › ProBuilder support › Bar Counter Display Current Day Only
- This topic has 10 replies, 3 voices, and was last updated 1 year ago by gadetrading.
-
-
09/05/2023 at 5:29 PM #220372
Hello,
Kindly asking for some help to tweak an indicator:
Can someone make this bar counter display only on the current day? So it doesn’t display on any prior day than today.Thank you,
Andreas123456789101112131415161718192021222324252627Once Count = 0StartSession=22EndSession=221500If OpenTime >= StartSession and OpenTime <= EndSession thenCount=Count+1xEven=Count/2 - Round(Count/2)If IntraDayBarIndex = 0 thenCount = 1EndIfIf Count > 0 and xEven=0 thenDrawText( "#Count#", BarIndex,Low-1*pipsize,SansSerif) COLOURED (153, 153, 153, 255)EndIfIf Time = EndSession thenCount=0EndIfEndifReturn09/05/2023 at 6:40 PM #22037709/05/2023 at 7:16 PM #220380Appreciate the reply, but this only shows it for the last bar. I want it to show on the entire current day on any time frame. So the 5 min chart may currently have say 32 bars or 79 bars on the current day, and I want it to show only on these bars.
09/05/2023 at 8:12 PM #22038109/05/2023 at 8:41 PM #220382No, this is not what I am trying to change. I still only want it to display odd numbers. I simply want it to display what’s its already doing but only on the current day, whatever length the current day may already have.
09/06/2023 at 6:24 AM #220388Hello,
1234567891011defparam drawonlastbaronly=trueCount=IntraDayBarIndexfor i=0 to countIf (Count[i] mod 2)<>0 thenvalcount=Count[i]DrawText( "#valcount#", BarIndex[i],Low[i]-1*pipsize,SansSerif) COLOURED (153, 153, 153, 255)EndIfnextReturn1 user thanked author for this post.
09/06/2023 at 9:34 AM #220396@JC_Bywan
Thank you sir. This only displays on the current day like requested.
But this code counts the first bar as bar 0, is it possible to change this so the first bar of the day is bar 1?
And I misspoke (sorry) in my last reply, I want it to display the even numbers only. Is this possible to fix?
I want it to display like in the screenshot:09/06/2023 at 9:51 AM #220402This version should change to first bar count = 1, and display even numbers.
Also included, a choice to select the most appropriate IF line, depending if the need is to display even numbers AND 1 as in screenshot, or only even numbers as in text. The unwanted IF line needs to be commented out thanks to // at beginning of line.
123456789101112defparam drawonlastbaronly=trueCount=IntraDayBarIndex+1for i=0 to count-1If Count[i]=1 or (Count[i] mod 2)=0 then // use to display even bar numbers AND also bar=1 as in screenshot//If (Count[i] mod 2)=0 then // use instead of above IF line to display ONLY even bar numbers as asked in text, not bar=1valcount=Count[i]DrawText( "#valcount#", BarIndex[i],Low[i]-1*pipsize,SansSerif) COLOURED (153, 153, 153, 255)EndIfnextReturn09/06/2023 at 10:26 AM #220413@JC_Bywan
This functions well! However, it seems to attempt to load on all the data in the chart which takes a lot of time for it to complete.
So switching between symbols now makes my CPU fan turn on. The original version (the one in my original post) did not do this even though it displayed bar numbers on a lot of data.
Is this possible to fix?09/06/2023 at 11:06 AM #220418If pc struggles, using islastbarupdate makes it possible to achieve same result with added bonus of skipping all unneeded earlier calculations to give CPU fan some rest when switching often:
1234567891011121314defparam drawonlastbaronly=trueCount=IntraDayBarIndex+1if islastbarupdate thenfor i=0 to count-1If Count[i]=1 or (Count[i] mod 2)=0 then // use to display even bar numbers AND also bar=1 as in image//If (Count[i] mod 2)=0 then // use instead of above IF line to display ONLY even bar numbers as asked in text, not bar=1valcount=Count[i]DrawText( "#valcount#", BarIndex[i],Low[i]-1*pipsize,SansSerif) COLOURED (153, 153, 153, 255)EndIfnextendifReturn1 user thanked author for this post.
09/06/2023 at 6:48 PM #220458Working great. You’re the best, thank you!
-
AuthorPosts
Find exclusive trading pro-tools on