Finding hourly highs/lows using 1 min data
Forums › ProRealTime English forum › ProOrder support › Finding hourly highs/lows using 1 min data
- This topic has 15 replies, 6 voices, and was last updated 7 years ago by Roman.
-
-
07/05/2016 at 4:01 PM #1024107/06/2016 at 7:21 AM #1025607/06/2016 at 10:29 AM #1026907/06/2016 at 10:32 AM #1027007/06/2016 at 3:26 PM #1027507/06/2016 at 3:33 PM #1027707/06/2016 at 3:38 PM #10278
This is what I wrote but – surprise, surprise- not working 🙁
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191REM Calculate 60min H/LH0 = 999999H1 = 999999H2 = 999999H3 = 999999H4 = 999999H5 = 999999H6 = 999999H7 = 999999H8 = 999999H9 = 999999H10 = 999999H11 = 999999H12 = 999999H13 = 999999H14 = 999999H15 = 999999H16 = 999999H17 = 999999H18 = 999999H19 = 999999H20 = 999999H21 = 999999H22 = 999999H23 = 999999L0 = 0L1 = 0L2 = 0L3 = 0L4 = 0L5 = 0L6 = 0L7 = 0L8 = 0L9 = 0L10 = 0L11 = 0L12 = 0L13 = 0L14 = 0L15 = 0L16 = 0L17 = 0L18 = 0L19 = 0L20 = 0L21 = 0L22 = 0L23 = 0if (Time = 005959) thenH0 = highest[60](high)L0 = lowest[60](low)endifif (Time = 015959) thenH1 = highest[60](high)L1 = lowest[60](low)endifif (Time = 025959) thenH2 = highest[60](high)L2 = lowest[60](low)endifif (Time = 035959) thenH3 = highest[60](high)L3 = lowest[60](low)endifif (Time = 045959) thenH4 = highest[60](high)L4 = lowest[60](low)endifif (Time = 055959) thenH5 = highest[60](high)L5 = lowest[60](low)endifif (Time = 065959) thenH6 = highest[60](high)L6 = lowest[60](low)endifif (Time = 075959) thenH7 = highest[60](high)L7 = lowest[60](low)endifif (Time = 085959) thenH8 = highest[60](high)L8 = lowest[60](low)endifif (Time = 095959) thenH9 = highest[60](high)L9 = lowest[60](low)endifif (Time = 105959) thenH10 = highest[60](high)L10 = lowest[60](low)endifif (Time = 115959) thenH11 = highest[60](high)L11 = lowest[60](low)endifif (Time = 125959) thenH12 = highest[60](high)L12 = lowest[60](low)endifif (Time = 135959) thenH13 = highest[60](high)L13 = lowest[60](low)endifif (Time = 145959) thenH14 = highest[60](high)L14 = lowest[60](low)endifif (Time = 155959) thenH15 = highest[60](high)L15 = lowest[60](low)endifif (Time = 165959) thenH16 = highest[60](high)L16 = lowest[60](low)endifif (Time = 175959) thenH17 = highest[60](high)L17 = lowest[60](low)endifif (Time = 185959) thenH18 = highest[60](high)L18 = lowest[60](low)endifif (Time = 195959) thenH19 = highest[60](high)L19 = lowest[60](low)endifif (Time = 205959) thenH20 = highest[60](high)L20 = lowest[60](low)endifif (Time = 215959) thenH21 = highest[60](high)L21 = lowest[60](low)endifif (Time = 225959) thenH22 = highest[60](high)L22 = lowest[60](low)endifif (Time = 235959) thenH23 = highest[60](high)L23 = lowest[60](low)endifonce BuyLine = 0if time = 010000 and (H0 < H21) thenBuyLine = H0elsif time = 010000 and (H0 < H22) thenBuyLine = H0elsif time = 010000 and (H0 < H23) thenBuyLine = H0elseBuyLine = BuyLine[1]endifif time = 020000 and (H1 < H22) thenBuyLine = H1elsif time = 020000 and (H1 < H23) thenBuyLine = H1elsif time = 020000 and (H1 < H0) thenBuyLine = H1elseBuyLine = BuyLine[1]endif08/18/2016 at 2:25 PM #11831Please try this with 1 Minute time Frame:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166REM Calculate 60min H/LOnce H0 = 999999Once H1 = 999999Once H2 = 999999Once H3 = 999999Once H4 = 999999Once H5 = 999999Once H6 = 999999Once H7 = 999999Once H8 = 999999Once H9 = 999999Once H10 = 999999Once H11 = 999999Once H12 = 999999Once H13 = 999999Once H14 = 999999Once H15 = 999999Once H16 = 999999Once H17 = 999999Once H18 = 999999Once H19 = 999999Once H20 = 999999Once H21 = 999999Once H22 = 999999Once H23 = 999999Once L0 = 0Once L1 = 0Once L2 = 0Once L3 = 0Once L4 = 0Once L5 = 0Once L6 = 0Once L7 = 0Once L8 = 0Once L9 = 0Once L10 = 0Once L11 = 0Once L12 = 0Once L13 = 0Once L14 = 0Once L15 = 0Once L16 = 0Once L17 = 0Once L18 = 0Once L19 = 0Once L20 = 0Once L21 = 0Once L22 = 0Once L23 = 0if (Time = 005900) thenH0 = highest[60](high)L0 = lowest[60](low)endifif (Time = 015900) thenH1 = highest[60](high)L1 = lowest[60](low)endifif (Time = 025900) thenH2 = highest[60](high)L2 = lowest[60](low)endifif (Time = 035900) thenH3 = highest[60](high)L3 = lowest[60](low)endifif (Time = 045900) thenH4 = highest[60](high)L4 = lowest[60](low)endifif (Time = 055900) thenH5 = highest[60](high)L5 = lowest[60](low)endifif (Time = 065900) thenH6 = highest[60](high)L6 = lowest[60](low)endifif (Time = 075900) thenH7 = highest[60](high)L7 = lowest[60](low)endifif (Time = 085900) thenH8 = highest[60](high)L8 = lowest[60](low)endifif (Time = 095900) thenH9 = highest[60](high)L9 = lowest[60](low)endifif (Time = 105900) thenH10 = highest[60](high)L10 = lowest[60](low)endifif (Time = 115900) thenH11 = highest[60](high)L11 = lowest[60](low)endifif (Time = 125900) thenH12 = highest[60](high)L12 = lowest[60](low)endifif (Time = 135900) thenH13 = highest[60](high)L13 = lowest[60](low)endifif (Time = 145900) thenH14 = highest[60](high)L14 = lowest[60](low)endifif (Time = 155900) thenH15 = highest[60](high)L15 = lowest[60](low)endifif (Time = 165900) thenH16 = highest[60](high)L16 = lowest[60](low)endifif (Time = 175900) thenH17 = highest[60](high)L17 = lowest[60](low)endifif (Time = 185900) thenH18 = highest[60](high)L18 = lowest[60](low)endifif (Time = 195900) thenH19 = highest[60](high)L19 = lowest[60](low)endifif (Time = 205900) thenH20 = highest[60](high)L20 = lowest[60](low)endifif (Time = 215900) thenH21 = highest[60](high)L21 = lowest[60](low)endifif (Time = 225900) thenH22 = highest[60](high)L22 = lowest[60](low)endifif (Time = 235900) thenH23 = highest[60](high)L23 = lowest[60](low)once BuyLine = 0if time = 010000 and (H0 < H21) thenBuyLine = H0elsif time = 010000 and (H0 < H22) thenBuyLine = H0elsif time = 010000 and (H0 < H23) thenBuyLine = H0elseBuyLine = BuyLine[1]endifif time = 020000 and (H1 < H22) thenBuyLine = H1elsif time = 020000 and (H1 < H23) thenBuyLine = H1elsif time = 020000 and (H1 < H0) thenBuyLine = H1elseBuyLine = BuyLine[1]endif08/18/2016 at 2:30 PM #1183208/18/2016 at 4:47 PM #11849Hi,
I would do it this way:
123456789101112// Hourly highs/lows using 1 min data responding to a request on PRC//// (but could also work for other timeframes lower than 1h, as long as each hourly candle and each lower timeframe candle end simultaneously, otherwise the code would be more complicated than this one - Noobywan)if OpenHour<>OpenHour[1] thenbarinit=intradaybarindexendifMaxthishour=highest[intradaybarindex-barinit+1](high)Minthishour=lowest[intradaybarindex-barinit+1](low)return Maxthishour as "Maxthishour", Minthishour as "Minthishour"08/19/2016 at 2:42 PM #11886Hi, don’t know if it’s the right answer to this question, but here is a solution to find the highest and lowest price each new hour:
12345678910111213//hourly high/lowonce ll = low[1]*1000if hour<>hour[1] thenhh = 0ll = low[1]*1000endifhh = max(hh,high)ll = min(ll,low)RETURN hh, ll08/19/2016 at 3:33 PM #1189308/19/2016 at 5:07 PM #1190205/06/2017 at 1:07 PM #3469905/06/2017 at 5:31 PM #34721Hallo, Nicolas,
I need highs and lows of the last 4 hours in 5 min chart. How must I modify the code to get the same timing as in 4H Chart, i.e. my segments have the same start und end time as in 4H chart – at 010000, 050000, 090000 and so on?
ONCE HH=0
ONCE LL=low[1]*1000
ONCE i = 0
ONCE hhigh = 0
ONCE llow = low[1]*1000if hour<>hour[1] then
if i = 4 then
HH=hhigh
LL=llow
TBarIndex=barindex
drawsegment(TBarindex,HH,barindex,hhigh)
drawsegment(TBarindex,LL,barindex,llow)
hhigh = 0
llow = low[1]*1000
i=0endif
i=i+1
endif
hhigh = max(hhigh,high)
llow = min(llow,low)return HH AS "NEWHIGH", LL AS "NEWLOW"
-
AuthorPosts
Find exclusive trading pro-tools on