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)
if minute=0 and (hour=0 or hour=4 or hour=8 or hour=12 or hour=16 or hour=20) then
hhigh = Highest[BarIndex - last4HourBarIndex](High)[1]
llow = Lowest[BarIndex - last4HourBarIndex](Low)[1]
cclose=close[0]
last4HourBarIndex = BarIndex[0]
firstbar=barindex[0]
endif
I’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)
//************************************
// Définition des paramètres du code
defparam 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 8H
noEntryBeforeTime = 080000
timeEnterBefore = 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 22H
noEntryAfterTime = 220000
timeEnterAfter = time < noEntryAfterTime
// Empêche le système de placer de nouveaux ordres le samedi ou dimanche
daysForbiddenEntry = OpenDayOfWeek = 6 OR OpenDayOfWeek = 0
//---------------------------------------------------------
graph4h = 1
//**********************************
// Définition PP 4h
if minute=0 and (hour=1 or hour=5 or hour=9 or hour=13 or hour=17 or hour=21) then
hhigh = Highest[BarIndex - last4HourBarIndex](High)[1]
llow = Lowest[BarIndex - last4HourBarIndex](Low)[1]
cclose=close[0]
last4HourBarIndex = BarIndex[0]
endif
Piv4h = (hhigh+llow+cclose)/3.0
if graph4H then
graph Piv4h as "pivH4"
endif
//-----------------------------------------------------
//************************************
MyRSI = RSI[14](close) >= 99
Vosconditions = MyRSI
if Vosconditions then
endif
// Conditions pour ouvrir une position acheteuse
if timeEnterBefore AND timeEnterAfter AND not daysForbiddenEntry then
if not LongOnMarket and VosConditions then
buy 1 contract at market
endif
endif
// Conditions pour fermer une position acheteuse
//If LongOnMarket AND VosConditions THEN
//SELL AT MARKET
//ENDIF
// Stops et objectifs : entrez vos stops et vos objectifs ici
set stop pLoss 10
set target pProfit 10
I 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.