Wrong Pivot points on Futures NQ and DJ
Forums › ProRealTime English forum › ProBuilder support › Wrong Pivot points on Futures NQ and DJ
- This topic has 52 replies, 6 voices, and was last updated 9 months ago by PeterSt.
-
-
02/07/2024 at 3:37 PM #227580For Test123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384ONCE DayH = highONCE DayL = lowONCE DayC = closeONCE FullDay = 0ONCE FullWeek = 0ONCE FullMonth = 0IF (OpenTime=010000 and dayofweek<>1) or (dayofweek<DAYOFWEEK[1]) THENdrawvline(barindex)if dayofweek <> 1 or (dayofweek<DAYOFWEEK[1]) THENPivotDuJour = (DHigh(1) + DLow(1) + DClose(1)) / 3elsif dayofweek = 1 thenPivotDuJour = (DHigh(2) + DLow(2) + DClose(2)) / 3endifMonthH = max(MonthH,DayH)MonthL = min(MonthL,DayL)MonthC = DayCWeekH = max(WeekH,DayH)WeekL = min(WeekL,DayL)WeekC = DayCpDayofWeekI = DayofWeekIpDayI = DayIpDayH = DayHpDayL = DayLpDayC = DayCDayofWeekI = DayofWeekDayI = DayDayH = HighDayL = LowDayC = CloseIf FullDay thenDayPivot = (pDayH + pDayL + pDayC)/3ElseDayPivot = undefinedFullDay = 1EndifIf DayofWeekI < pDayofWeekI thenpWeekH = WeekHpWeekL = WeekLpWeekC = WeekCWeekH = HighWeekL = LowWeekC = CloseIf FullWeek thenWeekPivot = (pWeekH + pWeekL + pWeekC)/3ElseWeekPivot = undefinedFullWeek = 1Endif//drawvline(barindex)EndifIf DayI < pDayI thenpMonthH = MonthHpMonthL = MonthLpMonthC = MonthCMonthH = HighMonthL = LowMonthC = CloseIf FullMonth thenMonthPivot = (pMonthH + pMonthL + pMonthC)/3ElseMonthPivot = undefinedFullMonth = 1Endif//drawvline(barindex)EndifENDIFDayH = max(DayH,high)DayL = min(DayL,low)DayC = closeReturn dayofweek
Can you test this last one at same barindex as previously ?
02/07/2024 at 4:47 PM #22758902/07/2024 at 5:39 PM #22759902/07/2024 at 6:01 PM #22760002/07/2024 at 6:11 PM #227603Yes it is a known problem on PRT with futures. That s why in one of the first post i have included a code correcting this.
Is your Nasdaq future is differnt from US Tech 100 CFD (from IG) ? If it is, tell me how you do to put the Nasdaq future on PRT so i will be able to solve your problem… The code i posted works for CFD index that have Dayofweek change at 1 am. Mayb i need an other broker ?
If i want to do the same for future i have to do sevral tests while coding it…
1 user thanked author for this post.
02/07/2024 at 6:16 PM #227604To access the futures you would need to use the “other” PRT (with broker IB) a demo account is enough. Probuilder code is the same.
Then instead of searching for us tech 100… you search for NQXXXX
Then you have the futures nasdaq in front of the eyes ! 🙂 thank you a lot
02/07/2024 at 6:22 PM #22760602/08/2024 at 5:09 AM #227625Now it works.
The problem was the use of Close[1] instead of DClose(1) which corresponds is the Settlement Price (Prix de Règlement) and can be different from Close[1].
Here the code which works and which “correct” also the PRT bug about the fact that the dayofWeek changes only at 7:00 on some futures.
MONTHLY pivots points123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990defparam drawonlastbaronly = truemyTime=TimemyDay=daymyMonth=monthmyYear=Yearif (myTime>=000000 and myTime<= 065959) thenmyDay=myDay+1if myYear <> myYear[1] thenif ((myYear mod 4 = 0) and (myYear mod 100 <> 0)) or (myYear mod 400 = 0) thenMaxDayInFeburary=29elseMaxDayInFeburary=28endifendifif myMonth=1 and myDay>31 thenmyMonth=2myDay=1elsif myMonth=2 and myDay>MaxDayInFeburary thenmyMonth=3myDay=1elsif myMonth=3 and myDay>31 thenmyMonth=4myDay=1elsif myMonth=4 and myDay>30 thenmyMonth=5myDay=1elsif myMonth=5 and myDay>31 thenmyMonth=6myDay=1elsif myMonth=6 and myDay>30 thenmyMonth=7myDay=1elsif myMonth=7 and myDay>31 thenmyMonth=8myDay=1elsif myMonth=8 and myDay>31 thenmyMonth=9myDay=1elsif myMonth=9 and myDay>30 thenmyMonth=10myDay=1elsif myMonth=10 and myDay>31 thenmyMonth=11myDay=1elsif myMonth=11 and myDay>30 thenmyMonth=12myDay=1elsif myMonth=12 and myDay>31 thenmyMonth=1myDay=1endifendif//PRC_MonthlyPivotPoints | indicator//26.10.2016//Nicolas @ www.prorealcode.com//Sharing ProRealTime knowledge//adapted from PRT original indicator//select mode of calculation of the Monthly pivot points (0,1,2)mode = 0If myMonth<>myMonth[1] thenMonthlyHigh = Highest[max(1,BarIndex - lastMonthBarIndex)](High)[1]MonthlyLow = Lowest[max(1,BarIndex - lastMonthBarIndex)](Low)[1]lastMonthBarIndex = BarIndexa=DClose(1)If mode = 0 thenMonthlyPivot = (MonthlyHigh + MonthlyLow + DClose(1)) / 3Elsif mode = 1 thenMonthlyPivot = (Open + MonthlyHigh + MonthlyLow + DClose(1)) / 4Elsif mode = 2 thenMonthlyPivot = (MonthlyHigh + MonthlyLow + DClose(1)*2) / 4ElseMonthlyPivot = (Open*2 + MonthlyHigh + MonthlyLow) / 4EndifMonthlyR1 = 2*MonthlyPivot - MonthlyLowMonthlyS1 = 2*MonthlyPivot - MonthlyHighMonthlyR2 = MonthlyPivot + (MonthlyHigh - MonthlyLow)MonthlyS2 = MonthlyPivot - (MonthlyHigh - MonthlyLow)MonthlyR3 = MonthlyR1 + (MonthlyHigh - MonthlyLow)MonthlyS3 = MonthlyS1 - (MonthlyHigh - MonthlyLow)Endif//return MonthlyPivot as "Monthly P", MonthlyR1 as "Monthly R1", MonthlyS1 as "Monthly S1", MonthlyR2 as "Monthly R2", MonthlyS2 as "Monthly S2", MonthlyR3 as "Monthly R3", MonthlyS3 as "Monthly S3"Thank you a lot LucasBest for your valuable support. If you see any improvements to be brought to this code, it is very welcome, I saw you publish a lot of good things here on the forum…
1 user thanked author for this post.
02/08/2024 at 5:48 AM #22762602/08/2024 at 6:25 AM #227628For 2023 I have just brought weeksofShift and TimeOfDayChange pfor managing the week difference between Paris and US…
weeksOfShift = (myMonth=3 and (myDay>=12 and myDay<=26)) or ((myMonth=10 and myDay>=29) or (myMonth=11 and myDay<=5))
if weeksOfShift then
TimeofDayChange=055959
else
TimeofDayChange=065959
endif1234567891011weeksOfShift = (myMonth=3 and (myDay>=12 and myDay<=26)) or ((myMonth=10 and myDay>=29) or (myMonth=11 and myDay<=5))if weeksOfShift thenTimeofDayChange=055959elseTimeofDayChange=065959endifif (myTime>=000000 and myTime<= TimeofDayChange) thenmyDay=myDay+1...................Now I am looking for a code which defines the date (day and month) of the last sunday of March and the last sunday of October automatically (for a given year)
02/08/2024 at 8:44 AM #227633Jerome, that will not help you, as it is not only about our Daylight Saving but also about the US. In the past years I experienced a difference that lasted 1 week, 2 weeks and even 3 weeks.
The rule in the US I don’t know. Ours is what you suggested (end of March etc.).Peter
1 user thanked author for this post.
02/08/2024 at 8:53 AM #22763402/08/2024 at 8:57 AM #227635The problem was the use of Close[1] instead of DClose(1) which corresponds is the Settlement Price (Prix de Règlement) and can be different from Close[1].
Wow, I did not know this existed. But exactly as what was asked here : and with this response from Nicolas :
Dclose returns the official daily close of the instrument.
which to me in the context of the “constant” is the same as No answer … would it be true indeed that for the DAX this would return 17:30 ? Please remember, the DAX closes at 22:00.
It would mean 22:00 for ES and NQ (etc.) which close at 23:00.Of course I like to believe you. Did you test this ? (which I could do myself – haha).
The manual (“Programming Guide” – ProBacktest and ProOrder) does not tell much about it. And if anything it is what Nicolas literally said (quote above). The manual speaks in the context of “and it does not depend on your TimeZone settings”. Not that I can warp my head around that. 🙂Curious …
02/08/2024 at 9:01 AM #227636Thank you Peter, I think you are right, a manual entry for each year is better
I am quite sure you don’t need this. So just in case :
12345678910111213141516DLS = 0 // 30-10-2022,PS. 0 = Normal. 1 = Autumn. 2 = Spring.If Date >= 20221031 and Date <= 20221104 thenDLS = 1 // Autumn. USA is one hour early.elsif Date >= 20230312 and Date <= 20230326 then // 11-03-2023,PS.DLS = 2 // Spring. USA is one hour early.endif// 29-10-2023,PS, Justadd a group for convenience (no difficult If/Else stuff).// And the above can even be used for more history backtesting.If Date >= 20231029 and Date <= 20231105 thenDLS = 1 // Autumn. USA is one hour early.elsif Date >= 20240310 and Date <= 20240331 thenDLS = 2 // Spring. USA is one hour early.endif1 user thanked author for this post.
02/08/2024 at 9:08 AM #227637… If DClose really would do what you describe, it would even solve the problem of White Thursday, Good Friday and other crazy stuff like following Easter on Monday which does not exist in the US, but where they these days make up various other holidays on such days (as Easter Monday). N.b.: I think in this thread you talked about this too ?
Anyway, we could make an indicator for that, so we can just see it coming, instead of trying to look it up for the xth time, knowing that IBKR is sparse with such data (IG is OK).PS: The crazy stuff is about not being able to judge your daily gain properly because it depends on the Settlement dates/times (DAX is a daily pain if you’re not used to it).
1 user thanked author for this post.
-
AuthorPosts
Find exclusive trading pro-tools on