Marking High & Low – Help Needed.
Forums › ProRealTime English forum › ProBuilder support › Marking High & Low – Help Needed.
- This topic has 7 replies, 2 voices, and was last updated 5 years ago by Andy_O.
-
-
02/07/2019 at 12:27 AM #90657
I’m trying to place an arrow over today’s highest and lowest bar of the day on a 1 hour chart (this will be applied to UK shares which have 9 bars a day between 8:00 & 16:30). If multiple bars match the High/Low of the day I would only like to highlight the first bar that matches.
I have limited experience with ProBuilder, so I decided to start by building an indicator that just highlights the bar that contains the high of the day. When I had that working I was going to add the low bar of the day and then limit it to highlighting only the first matching High/Low using the once command.
Unfortunately I’m having difficulty matching only the high of the day. No matter what I try, bars that don’t match the high of the day are being highlighted.
The first thing I tried was this.1234if OpenDate = today and high = dhigh(0) thenDRAWARROWDOWN(barindex, high)endifreturnI thought that this would work, but it was highlighting bars that didn’t match the day’s high, as shown in the attachment.
What seems to be happening is that when you use DHigh on a 1 hour chart it doesn’t give the high of the whole day, but instead gives the highest price reached so far in the day for each bar.
I.e. for the third bar of the day, DHigh only returns the highest price reached during the first three bars of the day, even though there is data available for the whole day. (WholeDayHigh would be a really useful constant to have)
After searching the forum for ideas, these are some of the things that I have tried.
All of them have the same problem of highlighting bars that don’t match the high of the day.
1234IF OpenDate = today and high = highest[9](high) thenDRAWARROWDOWN(barindex, high)endifreturnThis is also problematic because it looks back 9 bars and sometimes the IG data is missing bars. If there are one or more bars missing, looking back 9 bars would include some of the previous days data.
I also tried this.
1234567891011Newhighest=0FOR a = 0 TO 9 DOIF OpenDate = today and DHigh(a)>Newhighest THENNewhighest = DHigh(a)ENDIFNEXTif high = Newhighest thenDRAWARROWDOWN(barindex, high)endifreturnand this.
123456789101112131415WholeDayHigh = 0i = 0bars = 9WHILE OpenDate[i] = today and i < bars DO IF High[i]>WholeDayHigh THENWholeDayHigh = High[i]ENDIFi = i + 1WENDif high = WholeDayHigh thenDRAWARROWDOWN(barindex, high)endifreturnWhich all gave the same result.
Any help solving this would be much appreciated.
02/07/2019 at 12:36 AM #9065802/07/2019 at 12:45 AM #9065902/07/2019 at 1:18 AM #90660You can’t know what the days highest high or lowest low is until the day is over. Your indicator can only highlight what it already knows at any moment in time!
You need to know that a new day has started and then start recording the highest high and the lowest low and the barindex at each new HH and new LL and draw an arrow at the end of the day at those locations.
Something like this:
123456789101112131415161718if dayofweek <> dayofweek[1] thenDRAWARROWDOWN(hhindex, hh)DRAWARROWUP(llindex, ll)hh = closell = closeendifif high > hh thenhh = highhhindex = barindexendifif low < ll thenll = lowllindex = barindexendifreturn02/08/2019 at 12:24 AM #90803Hi Vonasi, I’m grateful for your help.
The code that you wrote works and highlights the high and low bars of the day, as shown below.
Unfortunately it doesn’t seem to work on the last day of the chart, which is what I need. Do you have any other ideas on how to do this?
02/08/2019 at 11:11 AM #90833It is not possible to know the days high before the day is over! If you are wanting the latest days most recent new high to be highlighted with an arrow and then all previous arrows to be deleted then this is not possible as once drawn an object cannot be deleted. You could try saving the last location and then drawing a different colour arrow over the top but this might look a bit messy. Maybe you would be better to just draw horizontal lines on the last bar only at the days highest high and lowest low that would then highlight what those levels are across the chart?
Something like this:
1234567891011121314defparam drawonlastbaronly = trueif dayofweek[1] <> dayofweek[2] thenhh = lowll = highendifhh = max(hh,high)ll = min(ll,low)drawhline(hh) coloured(0,128,0)drawhline(ll) coloured(128,0,0)return02/09/2019 at 2:44 PM #90934Hi Vonasi, thanks for taking the time to help me.
During testing I have noticed that PRT 10.1 and PRT 10.3 implement DHigh differently.
If DHigh worked in the same way in 10.3 as it did in 10.1 I think that the first version that I tried (shown below) would have worked. I have other indicators that use DHigh that work in 10.1 but not 10.3.
I have made a new post that shows the difference in the behaviour of DHigh between 10.1 and 10.3
12345if OpenDate = today and high = dhigh(0) thenDRAWARROWDOWN(barindex, high)endifreturn02/13/2019 at 2:58 PM #91297This is the code that I ended up using. I’ve added comments to the code in case it can help anybody that
has a similar problem.12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455REM . Highlight the first bar that matches the high of the day & the first bar that matches the low of the day on a 1 hour timeframe.//====== Set Market Closing Time ======MarketClose = 16// Set the time of the last hour of the market (16 for UK close, 23 for a 24 hour market).// If set to 24 only the high & low of the last day will be highlighted.//====== Check If Last Bar ======if openhour = MarketClose thenLastBar = 1elsif opendate = today and OpenHour = CurrentHour then // If market hasn't closed use current barLastBar = 1elseLastBar = 0endif//====== Reset Initial High & Low At The Start Of The Trading Day ======if intradaybarindex = 0 thenhh = open - 1// Set to "open - 1" to account for situations where the// daily high never exceeds the open.// In such a situation no value would ever be greater than// the opening price. If "open" had been used to set the initial high// no value would ever be returned when checked below (if high > hh)ll = open + 1endif//====== Record High/Low & BarIndex =====if high > hh thenhh = highhhindex = barindexendifif low < ll thenll = lowllindex = barindexendif//====== Draw Arrows ======// On the last bar of the day draw arrows at the high and low of the day// as recorded above (hh , ll). Offset these arrows to the bar indexes that// were recorded at the time of the high and the low (hhindex , llindex)if LastBar = 1 thenDRAWARROWDOWN(hhindex, hh)Coloured(0,0,0,255)DRAWARROWUP(llindex, ll)Coloured(0,0,0,255)endifreturn -
AuthorPosts
Find exclusive trading pro-tools on