Pivot Point 4h miscalculation on one day only: August 5, 2020
Forums › ProRealTime English forum › ProOrder support › Pivot Point 4h miscalculation on one day only: August 5, 2020
- This topic has 6 replies, 3 voices, and was last updated 3 years ago by Tanou.
-
-
08/20/2020 at 10:36 AM #142101
Hello everybody,
I’ve been looking at the different threads that offer some formula to calculate pivot points in order to use it in strategies and I’ve eventually used Nicolas’s that you may find here : https://www.prorealcode.com/prorealtime-indicators/fibonacci-pivots-points-4-hours-daily-weekly-monthly/
(Thank you very much Nicolas, you’ve been a tremendous help)
I’ve kept this part only (from line 50 to 56 in the original post)
Nicolas's part1234567if minute=0 and (hour=0 or hour=4 or hour=8 or hour=12 or hour=16 or hour=20) thenhhigh = Highest[BarIndex - last4HourBarIndex](High)[1]llow = Lowest[BarIndex - last4HourBarIndex](Low)[1]cclose=close[0]last4HourBarIndex = BarIndex[0]firstbar=barindex[0]endifI’ve changed the first line adding 1 to each hour because otherwise ProOrder wouldn’t take the right hour frames into account. Probably because I’m on a different time frame on PRT, but it doesn’t seem to matter really.
I’ve used it on the DAX30 and I have checked around 20 occurrences and it works like a charm… except on one day.
On August 5, 2020, from 9 am to 13 (so 8 to 12 with the normal time frame), the pivot point is supposed to be 12 658,53 but the code’s calculation makes it 12 656,27.
Previous close is 12682, previous high is 12688,3 and previous low is 12605,3.
It does the same from 5 pm to 9 (so 4 pm to 8 on a normal time frame) on the same day!
You may try it out for yourself with this bit of code :
(don’t forget to change the first line depending on your time frame)
Full code1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859//************************************// Définition des paramètres du codedefparam CumulateOrders = False // Cumul des positions désactivé// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position avant 8HnoEntryBeforeTime = 080000timeEnterBefore = time >= noEntryBeforeTime// Empêche le système de placer des ordres pour entrer sur le marché ou augmenter la taille d'une position après 22HnoEntryAfterTime = 220000timeEnterAfter = time < noEntryAfterTime// Empêche le système de placer de nouveaux ordres le samedi ou dimanchedaysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0//---------------------------------------------------------graph4h = 1//**********************************// Définition PP 4hif minute=0 and (hour=1 or hour=5 or hour=9 or hour=13 or hour=17 or hour=21) thenhhigh = Highest[BarIndex - last4HourBarIndex](High)[1]llow = Lowest[BarIndex - last4HourBarIndex](Low)[1]cclose=close[0]last4HourBarIndex = BarIndex[0]endifPiv4h = (hhigh+llow+cclose)/3.0if graph4H thengraph Piv4h as "pivH4"endif//-----------------------------------------------------//************************************MyRSI = RSI[14](close) >= 99Vosconditions = MyRSIif Vosconditions thenendif// Conditions pour ouvrir une position acheteuseif timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry thenif not LongOnMarket and VosConditions thenbuy 1 contract at marketendifendif// Conditions pour fermer une position acheteuse//If LongOnMarket AND VosConditions THEN//SELL AT MARKET//ENDIF// Stops et objectifs : entrez vos stops et vos objectifs iciset stop pLoss 10set target pProfit 10I have no idea why there’s a mistake or even where, so if you might help it would be very much appreciated!
Obviously, I haven’t checked all the possible pivot points but it might have happened elsewhere too without my knowing.
08/20/2020 at 4:22 PM #14215208/25/2020 at 3:06 PM #142529Hey thx for your help, I should have thought about it.
So for both Pivot Points, the mistake is that ProOrder doesn’t use the correct hhigh.
To calculate the PP from 9 am to 13, it uses the hhigh from the candle preceding the closing candle even if the high of the closing candle is higher. For example, with a 2-minute timeframe, it’ll take into consideration the candle from 08:56 to 08:58 instead of the candle from 08:58 to 09:00
To calculate the PP from 5 pm to 9, ProOrder uses the hhigh from the candle preceding the opening candle. For instance, with a 2-minute timeframe, it’ll take into consideration the candle from 12:58 to 13:00 instead of using the candle from 1:34 pm to 1:36.
It might seem that ProOrder’s calculation is always one candle late, meaning for example that it uses the 8:58 to 12:58 timeframe instead of the 09:00 to 13:00 timeframe to get its data. But it collects the correct data for cclose, which means it does include the last candle. Would it mean that it doesn’t include the last candle only to get the hhigh data (and maybe the llow too)?
Not sure what to do with that… If ever you have any ideas, please let me know.
08/26/2020 at 9:39 AM #14256908/27/2020 at 9:34 AM #142686Hey, it has had no effect. Either on hhigh values or llow values. Cclose hasn’t changed either though.
So I’ve checked a few other occurrencies and there’s also a discrepancy between the actual llows and the llows that ProOrder uses.
For example, on August 26 from 9pm to 1am (8pm to 0pm on a normal timeframe), ProOrder uses the llow from 4:58 to 5:00 when it should only consider the lows from 5:00 to 9:00 to make its calculations.
There are other similar examples the same day.
In view of the examples given above and the new ones, it leads me to assume that ProOrder (or the code) does use the correct timeframe to collect the cclose but does not to collect the hhigh and llow. It is even more strange that, when using the graph command, all values change at the same time, between the last candle of each 4-hour period.
10/23/2020 at 1:24 AM #148144@Tanou found the solution in another thread, many thanks!
In case anyone needs it, here it is:
PP4h calculation12345678910111213141516//Original code from Tanou// Calcul Points Pivots 4hInt = (OpenTime[1] < 010000 AND OpenTime > 010000) OR (OpenTime[1] < 050000 AND OpenTime > 050000) OR (OpenTime[1] < 090000 AND OpenTime > 090000) OR (OpenTime[1] < 130000 AND OpenTime > 130000) OR (OpenTime[1] < 170000 AND OpenTime > 170000) OR (OpenTime[1] < 210000 AND OpenTime > 210000) OR (Openday <> Openday[1] AND DayOfWeek < DayOfWeek[1])IF (OpenTime Mod 40000 = 10000) OR Int THENmyLastHigh = myHighmyLastLow = myLowmyLastClose = Close[1]myHigh = HighmyLow = LowELSEmyHigh = Max(myHigh, High)myLow = Min(myLow, Low)ENDIFPP = (myLastHigh + myLastLow + myLastClose) / 311/07/2020 at 12:20 AM #149738 -
AuthorPosts
Find exclusive trading pro-tools on