CFDs – Average Volume during Market hours
Forums › ProRealTime English forum › ProBuilder support › CFDs – Average Volume during Market hours
- This topic has 13 replies, 3 voices, and was last updated 4 years ago by robertogozzi.
-
-
12/25/2020 at 12:46 PM #155186
Hello, I’d like to:
1/ compare in Intraday current volume to Average[20](Volume) taking into account only volume during normal market hours, for example 9am to 5.30pm for DAX. The average should exclude volumes during the period 5.30pm to 9.00am next day.
2/ compare current volume (today) VS yesterday’s volume at the same time, for example volume today between 9.00am and 9.30am VS volume the day before between 9.00am and 9.30 am.
Thanks
12/25/2020 at 1:27 PM #155190Khaled – I guess that you are requesting someone to code you an indicator? If so then you have posted in the wrong forum. I have moved your topic to the place for indicators.
Post your topic in the correct forum:
_ ProRealTime Platform Support: only platform related issues.
_ ProOrder: only strategy topics.
_ ProBuilder: only indicator topics.
_ ProScreener: only screener topics
_ General Discussion: any other topics.
_ Welcome New Members: for new forum members to introduce themselves.12/26/2020 at 1:05 PM #15523612/28/2020 at 11:23 AM #155415Good morning, maybe my initial request was not clear enough…
Let’s assume:
volume 5 min bar closing at 17:25 is 50 (the previous day)
volume 5 min bar closing at 17:30 is 70 (the previous day)
volume 5 min bar closing at 08:50 is 100
volume 5 min bar closing at 08:55 is 120
volume 5 min bar closing at 09:00 is 200
volume 5 min bar closing at 09:05 is 250
I’d like to calculate the Simple Average Volume on last 4 bars excluding the time from 17:30pm to 08:59 am, i.e. average of (50, 70, 200, 250)=142.5
When I apply the condition
12345if time>=090000 and time<=173000 thenxVol = Average[4](Volume)endifthe first average calculated at 09:00 will take into account the four bars closing before 09:00, i.e. (09:00, 08:55, 08:50, 08:45)
Thank you for you help.
12/28/2020 at 12:02 PM #155422You can use such averages https://www.prorealcode.com/prorealtime-indicators/time-range-moving-averages-simple-exponential-weighted-trsma-trema-trwma/.
1 user thanked author for this post.
12/28/2020 at 2:38 PM #155440Thank you Roberto. I’m afraid this doesn’t solve my problem.
I have copied the “Time Range Simple Moving Average” code and changed “TRSMA” into “TRAV” (Time Range Average Volume” and replaced “Close” with “Volume”. Kept Periods = 20
Time Range Average Volume1234567891011121314151617181920212223242526// TRAV - Time Range Average VolumeDEFPARAM CalculateOnLastBars = 200//Periods = 20//StartTime = 090000//EndTime = 173000Periods = max(2,min(999,Periods))StartTime = max(0,min(240000,StartTime))EndTime = max(0,min(240000,EndTime))//i = 0TRAV = 0FOR j = 0 TO 3000IF opentime[j] >= StartTime AND opentime[j] <= EndTime THENTRAV = TRAV + Volume[j]i = i + 1IF i = Periods THENBREAKENDIFENDIFNEXTTRAV = (TRAV / Periods)IF TRAV = 0 THENTRAV = VolumeENDIFReturn TRAV AS "TRAV"On a 5 min TF, if you look at the candle starting 28 Dec. at 09:00 the volume is 1199 but the TRAV is 59.95 (1199/20). The second candle starting at 09:05 shows a volume of 727, so the average (from the begining of the day) shoud be = 963, but the TRAV shows 96.30 (dividing by 20 instead of dividing by the number of candles since 09:00am). So the code divides the cumulative volume by 20.
I tried to tweak the code to get this value corresponding to the average but I was unsuccesful.
Can you please look again at this (maybe using summation or average formula)?
Thanks a million.
12/28/2020 at 3:12 PM #155442Maybe this?
Only works on v11
1234567891011121314151617181920212223p = 4starttime = 090000endtime = 173000once avg = undefinedif opentime >= starttime and opentime < endtime thena = a + 1$vol[a] = volumeif a >=p thentotal = 0for b = a downto a-ptotal = total + $vol[b]nextavg = total/pendifelseavg = 0endifreturn avg1 user thanked author for this post.
12/28/2020 at 3:30 PM #15544312/28/2020 at 3:51 PM #155447Solved! Thank you very much for your help, Roberto and Vonasi!!!!
Average Volume Intraday1234567891011121314DEFPARAM CALCULATEONLASTBARS = 200// Average Volume IntradayIF time = 090000 thenbarstart= barindexENDIFIF time>=090000 and time<=173000 thenn = max(1, (intradaybarindex-barstart+1))AV = SUMMATION[n](volume)/ nENDIFRETURN AV as "Average Volume Intraday"As you can see, the Avg Vol on the first 30 min bar is equal to the volume of the first bar, works well for the second, etc.
12/28/2020 at 4:44 PM #15545812/28/2020 at 4:52 PM #15545912/28/2020 at 5:06 PM #155460This does the same thing:
1234567891011121314DEFPARAM CALCULATEONLASTBARS = 1000IF opentime = 090000 thenn = 0myvolume = 0endifIF opentime >= 090000 and opentime < 173000 thenn = n + 1myvolume = myvolume + volumeav = myvolume / nendifreturn av as "Average Volume Intraday"1 user thanked author for this post.
12/28/2020 at 5:17 PM #15546112/28/2020 at 5:29 PM #155464Good to hear you have solved it!
The average is made to account for PERIODS units, no matter the time. If your time starts at 9, it will consider 1 current bar + the last 19 bars of the previous day before 17:30.
Since volume was 0 last Thursday, actually it seems the average of the first candle is volume / 20 periods. NO, it’s the sum of the volume of the last 20 periods / 20 periods. Of course it considers only periods within the defined time range.
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on