How to identify the closest pivot points level to current price
Forums › ProRealTime English forum › ProOrder support › How to identify the closest pivot points level to current price
- This topic has 23 replies, 5 voices, and was last updated 5 years ago by GraHal.
Tagged: pivot, pivot points
-
-
02/11/2019 at 9:31 AM #9101302/11/2019 at 9:51 AM #9101402/11/2019 at 10:06 AM #9101502/11/2019 at 10:25 AM #9101702/11/2019 at 10:51 AM #91019
Okay so here is the ‘fixed’ code. It now correctly identifies the pivot directly above and below the last close. I am now trying to find the pivot levels two levels above an below the code. The logic I am now following is that I am measuring against either PivotAbove or PivotBelow instead of close. When graphed the results are correct here and there but often it either makes PivotAbove2 = PivotAbove or PivotBelow2 = PivotBelow
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416Defparam cumulateorders = False//pivot calculationsTimeframe(Monthly)MHigh = high[1]MClose = close[1]MLow = low[1]MPivot = (MHigh + MLow + MClose)/3 //Monthly Pivot CalculationMR1 = MPivot*2-MLowMS1 = MPivot*2-MHighMR2 = MPivot+(MHigh-MLow)MS2 = MPivot-(MHigh-MLow)MR3 = MHigh+(2*(MPivot-MLow))MS3 = MLow-(2*(MHigh-MPivot))Timeframe(Weekly)WHigh = high[1]WClose = close[1]WLow = low[1]WPivot = (WHigh + WLow + WClose)/3 //Weekly Pivot CalculationWR1 = WPivot*2-WLowWS1 = WPivot*2-WHighWR2 = WPivot+(WHigh-WLow)WS2 = WPivot-(WHigh-WLow)WR3 = WHigh+(2*(WPivot-WLow))WS3 = WLow-(2*(WHigh-WPivot))TImeframe(Default)If dayofweek = 1 ThenDPivot = (DHigh(2) + DLow(2) + DClose(2))/3 //Daily Pivot CalculationDR1 = DPivot*2-Dlow(2)DS1 = DPivot*2-DHigh(2)DR2 = DPivot+(DHigh(2)-DLow(2))DS2 = DPivot-(DHigh(2)-DLow(2))DR3 = DHigh(2)+(2*(DPivot-DLow(2)))DS3 = DLow(2)-(2*(DHigh(2)-DPivot))ElseDPivot = (DHigh(1) + DLow(1) + DClose(1))/3 //Daily Pivot CalculationDR1 = DPivot*2-Dlow(1)DS1 = DPivot*2-DHigh(1)DR2 = DPivot+(DHigh(1)-DLow(1))DS2 = DPivot-(DHigh(1)-DLow(1))DR3 = DHigh(1)+(2*(DPivot-DLow(1)))DS3 = DLow(1)-(2*(DHigh(1)-DPivot))EndIf//If MR1 + MS1 + MR2 + MS2 + MR3 + MS3 + Mpivot + WR1 + WS1 + WR2 + WS2 + WR3 + WS3 + Wpivot + DR1 + DS1 + DR2 + DS2 + DR3 + DS3 + Dpivot = 0 Then//EndIf//Find Pivot One Level Above and Below CloseIf MR1 > close ThenMR1Above = MR1MR1Below = 0ElsIf MR1 < close ThenMR1Below = MR1MR1Above = 100000EndIfIf MS1 > close ThenMS1Above = MS1MS1Below = 0ElsIf MS1 < close ThenMS1Below = MS1MS1Above = 100000EndIfIf MR2 > close ThenMR2Above = MR2MR2Below = 0ElsIf MR2 < close ThenMR2Below = MR2MR2Above = 100000EndIfIf MS2 > close ThenMS2Above = MS2MS2Below = 0ElsIf MS2 < close ThenMS2Below = MS2MS2Above = 100000EndIfIf MR3 > close ThenMR3Above = MR3MR3Below = 0ElsIf MR3 < close ThenMR3Below = MR3MR3Above = 100000EndIfIf MS3 > close ThenMS3Above = MS3MS3Below = 0ElsIf MS3 < close ThenMS3Below = MS3MS3Above = 100000EndIfIf MPivot > close ThenMPivotAbove = MPivotMPivotBelow = 0ElsIf MPivot < close ThenMPivotBelow = MPivotMPivotAbove = 100000EndIfIf WR1 > close ThenWR1Above = WR1WR1Below = 0ElsIf WR1 < close ThenWR1Below = WR1WR1Above = 100000EndIfIf WS1 > close ThenWS1Above = WS1WS1Below = 0ElsIf WS1 < close ThenWS1Below = WS1WS1Above = 100000EndIfIf WR2 > close ThenWR2Above = WR2WR2Below = 0ElsIf WR2 < close ThenWR2Below = WR2WR2Above = 100000EndIfIf WS2 > close ThenWS2Above = WS2WS2Below = 0ElsIf WS2 < close ThenWS2Below = WS2WS2Above = 100000EndIfIf WR3 > close ThenWR3Above = WR3WR3Below = 0ElsIf WR3 < close ThenWR3Below = WR3WR3Above = 100000EndIfIf WS3 > close ThenWS3Above = WS3WS3Below = 0ElsIf WS3 < close ThenWS3Below = WS3WS3Above = 100000EndIfIf WPivot > close ThenWPivotAbove = WPivotWPivotBelow = 0ElsIf WPivot < close ThenWPivotBelow = WPivotWPivotAbove = 100000EndIfIf DR1 > close ThenDR1Above = DR1DR1Below = 0ElsIf DR1 < close ThenDR1Below = DR1DR1Above = 100000EndIfIf DS1 > close ThenDS1Above = DS1DS1Below = 0ElsIf DS1 < close ThenDS1Below = DS1DS1Above = 100000EndIfIf DR2 > close ThenDR2Above = DR2DR2Below = 0ElsIf DR2 < close ThenDR2Below = DR2DR2Above = 100000EndIfIf DS2 > close ThenDS2Above = DS2DS2Below = 0ElsIf DS2 < close ThenDS2Below = DS2DS2Above = 100000EndIfIf DR3 > close ThenDR3Above = DR3DR3Below = 0ElsIf DR3 < close ThenDR3Below = DR3DR3Above = 100000EndIfIf DS3 > close ThenDS3Above = DS3DS3Below = 0ElsIf DS3 < close ThenDS3Below = DS3DS3Above = 100000EndIfIf DPivot > close ThenDPivotAbove = DPivotDPivotBelow = 0ElsIf DPivot < close ThenDPivotBelow = DPivotDPivotAbove = 100000EndIfPivotAbove = min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(MR1Above,MS1Above),MR2Above),MS2Above),MR3Above),MS3Above),MPivotAbove),WR1Above),WS1Above),WR2Above),WS2Above),WR3Above),WS3Above),WPivotAbove),DR1Above),DS1Above),DR2Above),DS2Above),DR3Above),DS3ABove),DPivotAbove)PivotBelow = max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(MR1Below,MS1Below),MR2Below),MS2Below),MR3Below),MS3Below),MPivotBelow),WR1Below),WS1Below),WR2Below),WS2Below),WR3Below),WS3Below),WPivotBelow),DR1Below),DS1Below),DR2Below),DS2Below),DR3Below),DS3Below),DPivotBelow)//Find Pivot Two Levels Above and Below CloseIf MR1 > PivotAbove ThenMR1Above2 = MR1MR1Below2 = 0ElsIf MR1 < PivotBelow ThenMR1Below2 = MR1MR1Above2 = 100000EndIfIf MS1 > PivotAbove ThenMS1Above2 = MS1MS1Below2 = 0ElsIf MS1 < PivotBelow ThenMS1Below2 = MS1MS1Above2 = 100000EndIfIf MR2 > PivotAbove ThenMR2Above2 = MR2MR2Below2 = 0ElsIf MR2 < PivotBelow ThenMR2Below2 = MR2MR2Above2 = 100000EndIfIf MS2 > PivotAbove ThenMS2Above2 = MS2MS2Below2 = 0ElsIf MS2 < PivotBelow ThenMS2Below2 = MS2MS2Above2 = 100000EndIfIf MR3 > PivotAbove ThenMR3Above2 = MR3MR3Below2 = 0ElsIf MR3 < PivotBelow ThenMR3Below2 = MR3MR3Above2 = 100000EndIfIf MS3 > PivotAbove ThenMS3Above2 = MS3MS3Below2 = 0ElsIf MS3 < PivotBelow ThenMS3Below2 = MS3MS3Above2 = 100000EndIfIf MPivot > PivotAbove ThenMPivotAbove2 = MPivotMPivotBelow2 = 0ElsIf MPivot < PivotBelow ThenMPivotBelow2 = MPivotMPivotAbove2 = 100000EndIfIf WR1 > PivotAbove ThenWR1Above2 = WR1WR1Below2 = 0ElsIf WR1 < PivotBelow ThenWR1Below2 = WR1WR1Above2 = 100000EndIfIf WS1 > PivotAbove ThenWS1Above2 = WS1WS1Below2 = 0ElsIf WS1 < PivotBelow ThenWS1Below2 = WS1WS1Above2 = 100000EndIfIf WR2 > PivotAbove ThenWR2Above2 = WR2WR2Below2 = 0ElsIf WR2 < PivotBelow ThenWR2Below2 = WR2WR2Above2 = 100000EndIfIf WS2 > PivotAbove ThenWS2Above2 = WS2WS2Below2 = 0ElsIf WS2 < PivotBelow ThenWS2Below2 = WS2WS2Above2 = 100000EndIfIf WR3 > PivotAbove ThenWR3Above2 = WR3WR3Below2 = 0ElsIf WR3 < PivotBelow ThenWR3Below2 = WR3WR3Above2 = 100000EndIfIf WS3 > PivotAbove ThenWS3Above2 = WS3WS3Below2 = 0ElsIf WS3 < PivotBelow ThenWS3Below2 = WS3WS3Above2 = 100000EndIfIf WPivot > PivotAbove ThenWPivotAbove2 = WPivotWPivotBelow2 = 0ElsIf WPivot < PivotBelow ThenWPivotBelow2 = WPivotWPivotAbove2 = 100000EndIfIf DR1 > PivotAbove ThenDR1Above2 = DR1DR1Below2 = 0ElsIf DR1 < PivotBelow ThenDR1Below2 = DR1DR1Above2 = 100000EndIfIf DS1 > PivotAbove ThenDS1Above2 = DS1DS1Below2 = 0ElsIf DS1 < PivotBelow ThenDS1Below2 = DS1DS1Above2 = 100000EndIfIf DR2 > PivotAbove ThenDR2Above2 = DR2DR2Below2 = 0ElsIf DR2 < PivotBelow ThenDR2Below2 = DR2DR2Above2 = 100000EndIfIf DS2 > PivotAbove ThenDS2Above2 = DS2DS2Below2 = 0ElsIf DS2 < PivotBelow ThenDS2Below2 = DS2DS2Above2 = 100000EndIfIf DR3 > PivotAbove ThenDR3Above2 = DR3DR3Below2 = 0ElsIf DR3 < PivotBelow ThenDR3Below2 = DR3DR3Above2 = 100000EndIfIf DS3 > PivotAbove ThenDS3Above2 = DS3DS3Below2 = 0ElsIf DS3 < PivotBelow ThenDS3Below2 = DS3DS3Above2 = 100000EndIfIf DPivot > PivotAbove ThenDPivotAbove2 = DPivotDPivotBelow2 = 0ElsIf DPivot < PivotBelow ThenDPivotBelow2 = DPivotDPivotAbove2 = 100000EndIfPivotAbove2 = min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(min(MR1Above2,MS1Above2),MR2Above2),MS2Above2),MR3Above2),MS3Above2),MPivotAbove2),WR1Above2),WS1Above2),WR2Above2),WS2Above2),WR3Above2),WS3Above2),WPivotAbove2),DR1Above2),DS1Above2),DR2Above2),DS2Above2),DR3Above2),DS3Above2),DPivotAbove2)PivotBelow2 = max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(max(MR1Below2,MS1Below2),MR2Below2),MS2Below2),MR3Below2),MS3Below2),MPivotBelow2),WR1Below2),WS1Below2),WR2Below2),WS2Below2),WR3Below2),WS3Below2),WPivotBelow2),DR1Below2),DS1Below2),DR2Below2),DS2Below2),DR3Below2),DS3Below2),DPivotBelow2)Graph PivotAbove coloured(255,0,0) as "Pivot Above"Graph PivotBelow coloured(0,255,0) as "Pivot Below"Graph PivotAbove2 coloured(255,0,0) as "Pivot Above 2"Graph PivotBelow2 coloured(0,255,0) as "Pivot Below 2"Buy possize contract at marketGraph close[1] coloured(0,0,0) as "close"//Graph MPivot coloured(255,0,0) as "MPivot"//Graph WPivot coloured(0,255,0) as "WPivot"//Graph DPivot coloured(0,0,255) as "DPivot" //DP 47173 DR1 47190 DR2 4722502/11/2019 at 12:03 PM #91028With this small code snippet, you’ll be able to find the nearest pivot points: (lines 26 to 89)
https://www.prorealcode.com/topic/fractal-systeme/page/2/#post-88943
Adapt it to weekly, monthly points..
1 user thanked author for this post.
02/11/2019 at 12:05 PM #91029I’ve now had time to actually read your code! I can’t explain why you sometimes get exactly the same values – maybe you need to graph every pivot line and see what their values actually are.
Also I notice sometimes that there may not actually be a pivot line above or below price and so you are left with a value of 10000 or zero. Not a major problem in a strategy as long as you take it into consideration in the code.
02/11/2019 at 12:17 PM #9103502/11/2019 at 12:45 PM #91042With this small code snippet, you’ll be able to find the nearest pivot points: (lines 26 to 89)
I just added above to here
-
AuthorPosts
Find exclusive trading pro-tools on