Retrieve highs and lows for a time period
Forums › ProRealTime English forum › ProScreener support › Retrieve highs and lows for a time period
- This topic has 2 replies, 3 voices, and was last updated 7 years ago by dakaodo.
-
-
11/05/2016 at 12:31 AM #15984
G’day,
I am looking for a way to retrieve the highs and lows that occur between a period of time. There are few theories that I would like to test using this data.
My broker offers only PRT 10.2 – I’ve read through the documentation and am unable find a way that would allow me to
- Cycle through a time period, say 9 to 5 and on 5 minute chart and retrieve the OHLC value just for this period
- Optionally return a pivot line of some sort with the midpoint calculated using data in #1
- Calculate standard deviations, moving averages etc only using data from this period.
In essence, I would like to be able to segregate price movements that occur over different time periods and apply standard indicators to test strategies.
Any help or nudge in the right direction would be much appreciated. Thank you!
11/06/2016 at 8:09 AM #16023You can do this I think. If not by changing your chart time settings, by code.
- To cycle through only a set time period on the intraday chart, to find the day’s current high for example, after 9 am before 5 pm.
1234567891011once DailyHigh=0if time=090000 thendailyhigh=highendifif time>=090000 and time<=170000 and high>dailyhigh thendailyhigh=highendifreturn high
- Midpoint would just be average, between high point as explained above and low point retrieved through same method.
- To calculate moving averages etc., you are in a more tricky situation. You will need to write code that alters the return of the standard indicators. A serious problem with PRT is that you cannot make your own arrays, you can only use built in arrays. However, you can make this work. I took your question as a challenge and made a simple moving average that takes into account what happened only upto 170000 yesterday when showing the morning’s moving average. From 170000 to 090000 it just shows normal moving average, not using custom time. Try it out:
12345678910111213141516171819202122232425262728293031323334353637myperiod=20once dailybardiff=1period=myperiodonce currperiod=1once lastrealbar=0once startbar=0final=average[myperiod]if currperiod<=period and currperiod>=0 thenmm=summation[dailybardiff](close)mm2=summation[dailybardiff+(period-currperiod-1)](close)endifif time=090000 thenstartbar=intradaybarindexdailybardiff=barindex-lastrealbarendifif time>=090000 and time<=1700000 thencurrperiod=intradaybarindex-startbarif currperiod>period thencurrperiod=periodendifif currperiod<period and currperiod>0 thenfirstadd=summation[currperiod](close)final=(mm2-mm+firstadd)/(period)endifendifif time=170000 thenlastrealbar=barindexendifreturn finalNote that this was done in a hurry, but I hope it answers your questions.
1 user thanked author for this post.
04/20/2017 at 10:03 PM #32815Hello, Wing!
Thank you for the initial bit of code to delimit times within a day. B/c of that, I was able to quickly replicate it 6 times to mark session highs and lows for NYC, London, and Tokyo. The user will have to set his own colors/line styles to differentiate them, but this was the fastest (15 mins) I’ve ever conceptualized and finished an indicator! 😀
I have two observations/questions:
I had to kludge the Tokyo session with two separate IF statements for each of high and low, where NYC and London only need one for high and one for low, to account for daily rollover at my local midnight. You can see the commented-out prior attempt with an OR condition to account for the daily rollover (didn’t work). Other users will have to enter in their local times for the three market sessions, and adjust accordingly. Is there a more elegant way to do this?
This indicator freaks out and does not display correctly when I switch to tick charts. I had a similar problem for a previous indicator. Is there a way to account for the difference in ??? timestamp data, duration of bars, I don’t know what, etc.?
The indicator works well enough for any minute/hour chart, so I am putting this open question out for the sake of learning better scripting/coding.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859once NYCHi=0once TOKHi=0once LONHi=0once NYClo=0once TOKlo=0once LONlo=0if time=070000 thenNYChi=highNYClo=lowendifif time>=070000 and time<=160000 and high>NYChi thenNYChi=highendifif time>=070000 and time<=160000 and low<NYClo thenNYClo=lowendifif time=010000 thenLONhi=highLONlo=lowendifif time>=010000 and time<=070000 and high>LONhi thenLONhi=highendifif time>=010000 and time<=070000 and low<LONlo thenLONlo=lowendifif time=180000 thenTOKhi=highTOKlo=lowendifif time>=180000 and time <=235959 and high>TOKhi then//if time>=180000 or time <=010000 and high>TOKhi thenTOKhi=highendifif time>=000000 and time <=010000 and high>TOKhi then//if time>=180000 or time <=010000 and high>TOKhi thenTOKhi=highendifif time>=180000 and time <=235959 and low<TOKlo then//if time>=180000 or time <=010000 and low<TOKlo thenTOKlo=lowendifif time>=000000 and time <=010000 and low<TOKlo then//if time>=180000 or time <=010000 and low<TOKlo thenTOKlo=lowendifreturn NYChi as "NYC high", LONhi as "LON high", TOKhi as "TOK high", NYClo as "NYC low", LONlo as "LON low", TOKlo as "TOK low" -
AuthorPosts
Find exclusive trading pro-tools on