Capture yesterday high low
Forums › ProRealTime English forum › ProBuilder support › Capture yesterday high low
- This topic has 13 replies, 2 voices, and was last updated 5 years ago by BC.
Viewing 14 posts - 1 through 14 (of 14 total)
-
-
04/28/2019 at 9:11 AM #97279
I want to capture yesterday (9:15 – 16:30) high low and show on today chart, but my code didn’t show correctly, what I did wrong?
1234567891011121314151617181920212223Once StartTime = 91500Once EndTime = 163000If Time >= StartTime and Time <= EndTime thenIf Time = StartTime thenDailyHigh = HighDailyLow = LowEndifIf High > DailyHigh thenDailyHigh = HighEndifIf Low < DailyLow thenDailyLow = LowEndifEndifreturn DailyHigh[1], DailyLow[1]04/28/2019 at 9:52 AM #97283You need to store yesterdays value before resetting and looking for todays value.
123456789101112131415161718192021222324Once StartTime = 91500Once EndTime = 163000If Time >= StartTime and Time <= EndTime thenIf Time = StartTime thenYesterdaysHigh = DailyHighYesterdaysLow = DailyLowDailyHigh = HighDailyLow = LowEndifIf High > DailyHigh thenDailyHigh = HighEndifIf Low < DailyLow thenDailyLow = LowEndifEndifreturn YesterdaysHigh, YesterdaysLowYou could also use MAX and MIN instead of all the IF and THEN’s.
12345678910111213141516171819Once StartTime = 91500Once EndTime = 163000If Time >= StartTime and Time <= EndTime thenIf Time = StartTime thenYesterdaysHigh = DailyHighYesterdaysLow = DailyLowDailyHigh = HighDailyLow = LowEndifDailyHigh = max(high,DailyHigh)DailyLow = min(low,Dailylow)Endifreturn YesterdaysHigh, YesterdaysLow04/28/2019 at 11:11 AM #9728610/20/2019 at 9:35 AM #11061910/20/2019 at 10:55 AM #110623Try this:
123456789101112131415161718192021222324StartTime = 091500EndTime = 163000once LastWeeksHigh = undefinedonce LastWeeksLow = undefinedif opendayofweek < opendayofweek[1] thenLastWeeksHigh = DailyHighLastWeeksLow = DailyLowfirsttime = 0endifIf not firsttime and Time = StartTime thenDailyHigh = HighDailyLow = Lowfirsttime = 1endifif firsttime and Time >= StartTime and Time <= EndTime thenDailyHigh = max(high,DailyHigh)DailyLow = min(low,Dailylow)Endifreturn LastWeeksHigh, LastWeeksLowEDIT : Code corrected 20191021
1 user thanked author for this post.
10/20/2019 at 12:51 PM #11063510/21/2019 at 2:32 PM #11071910/21/2019 at 2:36 PM #11072110/21/2019 at 3:42 PM #11073110/26/2019 at 4:11 AM #11124510/26/2019 at 9:43 AM #11125610/26/2019 at 9:46 AM #11125710/26/2019 at 10:09 AM #111261This code will do that – but be warned it is very slow to draw due to the loop.
1234567891011121314151617181920212223242526272829303132333435StartTime = 091500EndTime = 160000once myWeeksHigh = undefinedonce myWeeksLow = undefinedif opendayofweek < opendayofweek[1] thenfirsttime = 0endifIf not firsttime and Time = StartTime thenmyWeeksHigh = DailyHighmyWeeksLow = DailyLowweekindex = weekindex + 1DailyHigh = HighDailyLow = Lowfirsttime = 1endifif firsttime and openTime >= StartTime and opentime < EndTime thenDailyHigh = max(high,DailyHigh)DailyLow = min(low,Dailylow)endifif weekindex > lookback thenfor j = 1 to barindexif WeekIndex[j] = WeekIndex - lookback thenmyweekshigh = Dailyhigh[j]myweekslow = Dailylow[j]breakendifnextendifreturn myWeeksHigh, MyWeeksLow1 user thanked author for this post.
10/27/2019 at 4:04 AM #111305 -
AuthorPosts
Viewing 14 posts - 1 through 14 (of 14 total)
Find exclusive trading pro-tools on
Similar topics: