Coding for high and low between set hours
Forums › ProRealTime English forum › ProBuilder support › Coding for high and low between set hours
- This topic has 38 replies, 1 voice, and was last updated 3 years ago by Velociraptux.
-
-
05/18/2016 at 5:04 AM #7231
Hi,
I am currently coding a pivot indicator to use with Indexes. PRT already has a pivot indicator, but this runs from 12.00am to 11.59.59pm. This means that the pivots aren’t using cash data (10am – 4pm) and aren’t as effective.
What I am wanting to do is create a pivot indicator that uses the highest and lowest price between 10.00am and 4.00pm and uses the closing price at 4.00pm.
I am having little bit of trouble creating the logic for this. I can understand what I want it to say, but I can’t work out the correct programming language to use.
Basically..
Cashhigh = highest price of the prior weekday, between the hours of 10.00.00 and 16.00.00
Cashlow = lowest price of the prior weekday, between the hours of 10.00.00 and 16.00.00
Cash close = price at 16.00.00 of the prior weekday.
And what I mean by saying the prior weekday, is that if today is Monday looking at data from Friday between 10am-4pm, if today is Tuesday looking at data from Monday between 10am- 4pm, etc.
Does anyone have any pointers?
Thank you!
05/18/2016 at 10:53 AM #7246Hi Dave, need to know in which timeframe are you working in order to code it. In this example I’m using 15min chart, so variables Highest and Lowest are set to 24 (6 hours back) at 16:00h
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556DEFPARAM CUMULATEORDERS = FALSEREM ESTABLISH MAX AND MIN EACH DAY OF WEEKIF TIME=160000 AND DAYOFWEEK=1 THENCashHighMo = Highest[24](high)CashLowMo = Lowest[24](low)ENDIFIF TIME=160000 AND DAYOFWEEK=2 THENCashHighTu = Highest[24](high)CashLowTu = Lowest[24](low)ENDIFIF TIME=160000 AND DAYOFWEEK=3 THENCashHighWe = Highest[24](high)CashLowWe = Lowest[24](low)ENDIFIF TIME=160000 AND DAYOFWEEK=4 THENCashHighTh = Highest[24](high)CashLowTh = Lowest[24](low)ENDIFIF TIME=160000 AND DAYOFWEEK=5 THENCashHighFr = Highest[24](high)CashLowFr = Lowest[24](low)ENDIFIF DAYOFWEEK=1 AND close>CashHighFr THENBUY 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=2 AND close>CashHighMo THENBUY 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=3 AND close>CashHighTu THENBUY 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=4 AND close>CashHighWe THENBUY 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=5 AND close>CashHighTh THENBUY 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=1 AND Close<CashLowFr THENSELLSHORT 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=2 AND Close<CashLowMo THENSELLSHORT 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=3 AND Close<CashLowTu THENSELLSHORT 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=4 AND Close<CashLowWe THENSELLSHORT 1 CONTRACT AT MARKETENDIFIF DAYOFWEEK=5 AND Close<CashLowTh THENSELLSHORT 1 CONTRACT AT MARKETENDIF1 user thanked author for this post.
05/18/2016 at 11:17 AM #7249Sorry Dave, I did it for ProOrder before…
This one is for ProBuilder
1234567891011121314151617181920212223REM ESTABLISH MAX AND MIN EACH DAY OF WEEKIF TIME=160000 AND DAYOFWEEK=1 THENCashHighMo = Highest[24](high)CashLowMo = Lowest[24](low)ENDIFIF TIME=160000 AND DAYOFWEEK=2 THENCashHighTu = Highest[24](high)CashLowTu = Lowest[24](low)ENDIFIF TIME=160000 AND DAYOFWEEK=3 THENCashHighWe = Highest[24](high)CashLowWe = Lowest[24](low)ENDIFIF TIME=160000 AND DAYOFWEEK=4 THENCashHighTh = Highest[24](high)CashLowTh = Lowest[24](low)ENDIFIF TIME=160000 AND DAYOFWEEK=5 THENCashHighFr = Highest[24](high)CashLowFr = Lowest[24](low)ENDIFreturn CashHighMo as "Max Monday",CashLowMo as "Min Monday",CashHighTu as "Max Tuesday",CashLowTu as "Min Tuesday",CashHighWe as "Max Wednesday",CashLowWe as "Min Wednesday",CashHighTh as "Max Thursday",CashLowTh as "Min Thursday",CashHighFr as "Max Friday",CashLowFr as "Min Friday"1 user thanked author for this post.
05/18/2016 at 12:00 PM #7255Simplified
12345678910111213141516171819202122232425262728293031323334353637383940414243REM ESTABLISH MAX AND MIN EACH DAY OF WEEKIF DAYOFWEEK=1 THENMAXIMO = CashHighFrMINIMO = CashLowFrIF TIME=160000 THENCashHighMo = Highest[24](high)CashLowMo = Lowest[24](low)ENDIFENDIFIF DAYOFWEEK=2 THENMAXIMO = CashHighMoMINIMO = CashLowMoIF TIME=160000 THENCashHighTu = Highest[24](high)CashLowTu = Lowest[24](low)ENDIFENDIFIF DAYOFWEEK=3 THENMAXIMO = CashHighTuMINIMO = CashLowTuIF TIME=160000 THENCashHighWe = Highest[24](high)CashLowWe = Lowest[24](low)ENDIFENDIFIF DAYOFWEEK=4 THENMAXIMO = CashHighWeMINIMO = CashLowWeIF TIME=160000 THENCashHighTh = Highest[24](high)CashLowTh = Lowest[24](low)ENDIFENDIFIF DAYOFWEEK=5 THENMAXIMO = CashHighThMINIMO = CashLowThIF TIME=160000 THENCashHighFr = Highest[24](high)CashLowFr = Lowest[24](low)ENDIFENDIFreturn MAXIMO AS "LAST DAY MAX",MINIMO AS "LAST DAY LOW"05/19/2016 at 10:14 AM #7332ADOLFO YOU ARE AMAZING!!!!
I worked out how to do the cash close from what you have written!
I have a question though, is it possible to get it to look at the highest and lowest prices between 10am-4pm without having to adjust the number of bars within the highest/lowest brackets.
It just makes it challenging to flick between time frames, which I do often. 🙂
Thank you so much for you help!
12345678910111213141516171819202122232425262728293031323334REM ESTABLISHED CLOSE OF MARKETIF DAYOFWEEK=1 THENcashclose=CashCloseFrIF TIME=160000 THENCashCloseMo = CloseENDIFENDIFIF DAYOFWEEK=2 THENcashclose=CashCloseMoIF TIME=160000 THENCashCloseTu = CloseENDIFENDIFIF DAYOFWEEK=3 THENcashclose=CashCloseTuIF TIME=160000 THENCashCloseWe = CloseENDIFENDIFIF DAYOFWEEK=4 THENcashclose=CashCloseWeIF TIME=160000 THENCashCloseTh = CloseENDIFENDIFIF DAYOFWEEK=5 THENcashclose=CashCloseThIF TIME=160000 THENCashCloseFr = CloseENDIFENDIFreturn cashclose AS "CASHCLOSE"05/19/2016 at 11:37 AM #7336You’re wellcome Dave!
I think we can’t use “TIMEFRAME” function in ProBuilder, as far as I know is only for ProScreener at the moment, but I got an idea about “TIME“, maybe it will test bar by bar and know which timeframe are we using, and then we can set Highest and Lowest brackets with the right numbers.
On it, will be back with news.
05/19/2016 at 11:41 AM #7340Awesome thanks!
I actually had a break through. But the problem is that it is taking the value from 9am and I am unsure how to stop it. Or what I am doing right or wrong, or even what in the code is redundant! For example not sure whether the line below is doing anything.
1IF TIME<160000 and time>100000 THENGetting closer!
Thanks!
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556REM ESTABLISH MAX AND MIN EACH DAY OF WEEKIF DAYOFWEEK=1 THENMAXIMO = CashHighFrMINIMO = CashLowFrcashclose=CashCloseFrIF TIME<160000 and time>100000 THENCashHighMo = ( DHIGH(0))CashLowMo =( DLOW(0))CashCloseMo = CloseENDIFENDIFIF DAYOFWEEK=2 THENMAXIMO = CashHighMoMINIMO = CashLowMocashclose=CashCloseMoIF TIME<160000 and time>100000 THENCashHighTu = ( DHIGH(0))CashLowTu = ( DLOW(0))CashCloseTu = CloseENDIFENDIFIF DAYOFWEEK=3 THENMAXIMO = CashHighTuMINIMO = CashLowTucashclose=CashCloseTuIF TIME<160000 and time>100000 THENCashHighWe = ( DHIGH(0))CashLowWe = ( DLOW(0))CashCloseWe = CloseENDIFENDIFIF DAYOFWEEK=4 THENMAXIMO = CashHighWeMINIMO = CashLowWecashclose=CashCloseWeIF TIME<160000 and time>100000 THENCashHighTh = ( DHIGH(0))CashLowTh = ( DLOW(0))CashCloseTh = CloseENDIFENDIFIF DAYOFWEEK=5 THENMAXIMO = CashHighThMINIMO = CashLowThcashclose=CashCloseThIF TIME<160000 and time>100000 THENCashHighFr = ( DHIGH(0))CashLowFr = ( DLOW(0))CashCloseFr = CloseENDIFENDIFreturn MAXIMO AS "LAST DAY MAX",MINIMO AS "LAST DAY LOW", cashclose AS "CASH CLOSE"105/19/2016 at 12:29 PM #7343Looks nice! Still working on how to know wich timeframe is using, as far as i’m testing on 15 min chart, this works ok but when i change timeframe, it won’t, YET! 😉
1234567891011base = 360 // 1 minute, 6 hours backactualbar = Timelastbar = Time[1]period = actualbar-lastbarn = abs(round(periodo/base))x = abs(round(base/n)) // Result is 24 so works on 15 mins..IF DAYOFWEEK=1 THENMAXIMO = CashHighFrMINIMO = CashLowFrCashHighMo = Highest[x](high)CashLowMo = Lowest[x](low)……………………………………………………….
I’ll have a break and continue later, gl!
05/19/2016 at 12:53 PM #7347And… Here it is 🙂 ( Hope so )
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849REM ESTABLISH MAX AND MIN EACH DAY OF WEEKIF TIME=160000 THENbase = 360horaanterior = Time[1]periodo = 156000-horaanteriorn = abs(round(periodo/100))x = abs(round(base/n))IF DAYOFWEEK=1 THENMAXIMO = CashHighFrMINIMO = CashLowFrCashHighMo = Highest[x](high)CashLowMo = Lowest[x](low)CashCloseMo = CloseCashClose = CashCloseFrENDIFIF DAYOFWEEK=2 THENMAXIMO = CashHighMoMINIMO = CashLowMoCashHighTu = Highest[x](high)CashLowTu = Lowest[x](low)CashCloseTu = CloseCashClose = CashCloseMoENDIFIF DAYOFWEEK=3 THENMAXIMO = CashHighTuMINIMO = CashLowTuCashHighWe = Highest[x](high)CashLowWe = Lowest[x](low)CashCloseWe = CloseCashClose = CashCloseTuENDIFIF DAYOFWEEK=4 THENMAXIMO = CashHighWeMINIMO = CashLowWeCashHighTh = Highest[x](high)CashLowTh = Lowest[x](low)CashCloseTh = CloseCashClose = CashCloseWeENDIFIF DAYOFWEEK=5 THENMAXIMO = CashHighThMINIMO = CashLowThCashHighFr = Highest[x](high)CashLowFr = Lowest[x](low)CashCloseFr = CloseCashClose = CashCloseThENDIFENDIFreturn MAXIMO AS "LAST DAY MAX",MINIMO AS "LAST DAY LOW",CashClose as "Cash Close"1 user thanked author for this post.
05/20/2016 at 6:08 AM #7432Thanks Adolfo!
That is great and it works on any time frame!
There is a little problem though, I just put it on the chart and it is a 1 day out, what I mean is that the high and low from Monday, instead of being shown on the Tuesday, is shown on the day after on the Wednesday.
Is there an easy fix I tried fiddling with the code but couldn’t work it out? 🙂
So on the picture the high, lows and close need to be a day earlier. Where the red lines are drawn.
Thanks Adolfo, I am super appreciative of the effort you have put in!
-Dave
05/20/2016 at 8:08 AM #743705/20/2016 at 8:39 AM #7442Dave, after check it on my chart, didn’t find any error, here is the code and screenshot. Can you confirm we got the same?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849REM ESTABLISH MAX AND MIN EACH DAY OF WEEKIF TIME=160000 THENbase = 360horaanterior = Time[1]periodo = 156000-horaanteriorn = abs(round(periodo/100))x = abs(round(base/n))IF DAYOFWEEK=1 THENMAXIMO = CashHighFrMINIMO = CashLowFrCashHighMo = Highest[x](high)CashLowMo = Lowest[x](low)CashCloseMo = CloseCashClose = CashCloseFrENDIFIF DAYOFWEEK=2 THENMAXIMO = CashHighMoMINIMO = CashLowMoCashHighTu = Highest[x](high)CashLowTu = Lowest[x](low)CashCloseTu = CloseCashClose = CashCloseMoENDIFIF DAYOFWEEK=3 THENMAXIMO = CashHighTuMINIMO = CashLowTuCashHighWe = Highest[x](high)CashLowWe = Lowest[x](low)CashCloseWe = CloseCashClose = CashCloseTuENDIFIF DAYOFWEEK=4 THENMAXIMO = CashHighWeMINIMO = CashLowWeCashHighTh = Highest[x](high)CashLowTh = Lowest[x](low)CashCloseTh = CloseCashClose = CashCloseWeENDIFIF DAYOFWEEK=5 THENMAXIMO = CashHighThMINIMO = CashLowThCashHighFr = Highest[x](high)CashLowFr = Lowest[x](low)CashCloseFr = CloseCashClose = CashCloseThENDIFENDIFreturn MAXIMO AS "LAST DAY MAX",MINIMO AS "LAST DAY LOW",CashClose as "Cash Close"05/20/2016 at 9:04 AM #7449Hi Adolfo,
I just uploaded your .itf file, and it is 24 hrs out 🙂 As soon as the session finishes the max and min should move to the high and low of the session that has just finished, but instead it goes to max and min of the session before.
So Mondays max and min is on Wednesday’s session but it should be on Tuesdays 🙂
Thanks 🙂
05/20/2016 at 9:19 AM #7450Just to confirm, my charts are at GMT+2.
So now, we got the new max and min changing at 16:00h, to lastday before. You mean they should change each new session (00:00 or intradaybarindex=0).
Each new day, max, min and close should be: max-min between 10-16 and yesterday close, is it ok?
05/20/2016 at 9:56 AM #7451Finally.. Got it!! :):):)… As far as it only works from 1m to 1h…
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061REM ESTABLISH MAX AND MIN EACH DAY OF WEEKbase = 360periodo = 006000-horaanteriorn = abs(round(periodo/100))x = abs(round(base/n))IF TIME=010000 THENhoraanterior = Time[1]endifIF DAYOFWEEK=1 THENMAXIMO = CashHighFrMINIMO = CashLowFrCashClose = DClose(1)IF TIME = 160000 THENCashHighMo = Highest[x](high)CashLowMo = Lowest[x](low)ENDIFENDIFIF DAYOFWEEK=2 THENMAXIMO = CashHighMoMINIMO = CashLowMoCashClose = DClose(1)IF TIME = 160000 THENCashHighTu = Highest[x](high)CashLowTu = Lowest[x](low)ENDIFENDIfIF DAYOFWEEK=3 THENMAXIMO = CashHighTuMINIMO = CashLowTuCashClose = DClose(1)IF TIME = 160000 THENCashHighWe = Highest[x](high)CashLowWe = Lowest[x](low)ENDIFENDIFIF DAYOFWEEK=4 THENMAXIMO = CashHighWeMINIMO = CashLowWeCashClose = DClose(1)IF TIME = 160000 THENCashHighTh = Highest[x](high)CashLowTh = Lowest[x](low)ENDIFENDIFIF DAYOFWEEK=5 THENMAXIMO = CashHighThMINIMO = CashLowThCashClose = DClose(1)IF TIME = 160000 THENCashHighFr = Highest[x](high)CashLowFr = Lowest[x](low)ENDIFENDIFreturn MAXIMO AS "LAST DAY MAX",MINIMO AS "LAST DAY LOW",CashClose as "Cash Close"1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on