retro69
Newbie
- Messages
- 6
- Likes
- 1
Hi. I wonder if anyone can help me. I have found some code and successfully modified it to work with Monthly, Weekly,Daily, and 1h Pivots, however its beyond me how I can get this to work with 4h Pivots. I know we have some really great programmers on the boards and I hope someone could help me. I have included the code below for the Daily and Weekly Pivots.
Its for the ProRealTime software I use.
If anyone can tell me how to get the code below working for 4h pivots, or show me where im going wrong I would be extremely grateful!
------------------------------
Weekly Pivots
--------------------------------
IF DAYOFWEEK < DAYOFWEEK[1] THEN
weekhigh = prevweekhigh
weeklow = prevweeklow
weekclose = prevweekclose
prevweekhigh = HIGH
prevweeklow = LOW
ENDIF
prevweekhigh = MAX(prevweekhigh, HIGH)
prevweeklow = MIN(prevweeklow, LOW)
prevweekclose = CLOSE
PP = (weekhigh + weeklow + weekclose)/3
// RANGE = PREVIOUS DAY'S HIGH - PREVOIUS DAY'S LOW
PRANGE = weekhigh - weeklow
// Resistance 2 : PP+RANGE
PR2 = PP + PRANGE
// Résistance 1 : (2*PP)-LOW
PR1 = 2 * PP - weeklow
//R3 := 2*PP + (high - 2*low);
PR3 = 2* PP + (weekhigh - (2*weeklow))
// Support 1 : (2*PP)-H
PS1 = 2 * PP - weekhigh
// Support 2 : PP-RANGE
PS2 = PP - PRANGE
// S3 := 2*PP - (2*high - low);
PS3 = 2*PP - (2*weekhigh-weeklow)
// MID POINT BETWEEN S2 AND RS3
M0 = (PS2 + PS3) / 2
// MID POINT BETWEEN S2 AND R1
M1 = (PS2 + PS1) / 2
// MID POINT BETWEEN PP AND S1
M2 = (PP + PS1) / 2
// MID POINT BETWEEN PP AND R1
M3 = (PP + PR1) / 2
// MID POINT BETWEEN R2 AND R1
M4 = (PR2 + PR1) / 2
//MID POINT BETWEEN R2 AND R3;
M5 = (PR2 + PR3)/2
RETURN PR3 as "Res3" ,PR2 AS "Res2" , M4 AS "M4" , PR1 AS "Res1" , PS3 AS "Sup 3" ,M3 AS "M3" , PP AS "Pivot" , M2 AS "M2" , PS1 AS "Sup1" , M1 AS "M1" , PS2 AS "Sup2" ,M5 as "M5" , M0 AS "MO"
-----------------------------------
Daily Pivots
------------------------------------
REM Daily Pivot Points indicator - Use on intraday charts only.
pivotmethod = 0
IF BARINDEX = 0 THEN
initialization = 2 // we are in the middle of a day
resistance3 = UNDEFINED
resistance2 = UNDEFINED
resistance1 = UNDEFINED
p = UNDEFINED
support1 = UNDEFINED
support2 = UNDEFINED
support3 = UNDEFINED
M0 = UNDEFINED
M1 = UNDEFINED
M2 = UNDEFINED
M3 = UNDEFINED
M4 = UNDEFINED
M5 = UNDEFINED
ELSE
IF DAYOFWEEK[1] <> DAYOFWEEK THEN
prevmax = newmax
prevmin = newmin
prevclose = newclose
newmax = HIGH
newmin = LOW
newopen = OPEN
newclose = CLOSE
initialization = MAX(0, initialization - 1)
// initialization = 1 means that we are in the first entire day
// initialization = 0 means that we are in at least the second day
ELSE
newmax = MAX(newmax, HIGH)
newmin = MIN(newmin, LOW)
newclose = close
// uniquement apres les initialisations
IF initialization = 0 THEN
IF pivotmethod = 0 THEN
p = (prevmax + prevmin + prevclose) / 3
ELSIF pivotmethod = 1 THEN
p = (prevmax + prevmin + prevclose + newopen) / 4
ELSE
p = (prevmax + prevmin + newopen) / 3
ENDIF
resistance2 = p + (resistance1-support1)
resistance1 = (2 * p) - prevmin
P = p
support1 = (2 * p) - prevmax
support2 = p - (resistance1 - support1)
REM Formula for midpoints, S3 and R3 lines, remove comments to activate them and replace the "return line in the code with the commented return line below it.
resistance3 = prevmax + 2*(p-prevmin)
support3 = prevmin - 2*(prevmax-p)
M0 = (support3 + support2)/2
M1 = (support2 + support1)/2
M2 = (support1+p)/2
M3 = (resistance1+ p)/2
M4 = (resistance1+resistance2)/2
M5 = (resistance2+resistance3)/2
ENDIF
ENDIF
ENDIF
//RETURN resistance2 as "R2" , resistance1 as "R1" , P as "pivot" , support1 as "S1" , support2 as "S2"
Return M0 as "M0 Daily", M1 as "M1 Daily", M2 as "M2 Daily", M3 as "M3 Daily", M4 as "M4 Daily", M5 as "M5 Daily", resistance2 as "R2 Daily" , resistance1 as "R1 Daily" , P as "pivot Daily" , support1 as "S1 Daily" , support2 as "S2 Daily", resistance3 as "R3 Daily", support3 as "S3 Daily"
----------------------
Its for the ProRealTime software I use.
If anyone can tell me how to get the code below working for 4h pivots, or show me where im going wrong I would be extremely grateful!
------------------------------
Weekly Pivots
--------------------------------
IF DAYOFWEEK < DAYOFWEEK[1] THEN
weekhigh = prevweekhigh
weeklow = prevweeklow
weekclose = prevweekclose
prevweekhigh = HIGH
prevweeklow = LOW
ENDIF
prevweekhigh = MAX(prevweekhigh, HIGH)
prevweeklow = MIN(prevweeklow, LOW)
prevweekclose = CLOSE
PP = (weekhigh + weeklow + weekclose)/3
// RANGE = PREVIOUS DAY'S HIGH - PREVOIUS DAY'S LOW
PRANGE = weekhigh - weeklow
// Resistance 2 : PP+RANGE
PR2 = PP + PRANGE
// Résistance 1 : (2*PP)-LOW
PR1 = 2 * PP - weeklow
//R3 := 2*PP + (high - 2*low);
PR3 = 2* PP + (weekhigh - (2*weeklow))
// Support 1 : (2*PP)-H
PS1 = 2 * PP - weekhigh
// Support 2 : PP-RANGE
PS2 = PP - PRANGE
// S3 := 2*PP - (2*high - low);
PS3 = 2*PP - (2*weekhigh-weeklow)
// MID POINT BETWEEN S2 AND RS3
M0 = (PS2 + PS3) / 2
// MID POINT BETWEEN S2 AND R1
M1 = (PS2 + PS1) / 2
// MID POINT BETWEEN PP AND S1
M2 = (PP + PS1) / 2
// MID POINT BETWEEN PP AND R1
M3 = (PP + PR1) / 2
// MID POINT BETWEEN R2 AND R1
M4 = (PR2 + PR1) / 2
//MID POINT BETWEEN R2 AND R3;
M5 = (PR2 + PR3)/2
RETURN PR3 as "Res3" ,PR2 AS "Res2" , M4 AS "M4" , PR1 AS "Res1" , PS3 AS "Sup 3" ,M3 AS "M3" , PP AS "Pivot" , M2 AS "M2" , PS1 AS "Sup1" , M1 AS "M1" , PS2 AS "Sup2" ,M5 as "M5" , M0 AS "MO"
-----------------------------------
Daily Pivots
------------------------------------
REM Daily Pivot Points indicator - Use on intraday charts only.
pivotmethod = 0
IF BARINDEX = 0 THEN
initialization = 2 // we are in the middle of a day
resistance3 = UNDEFINED
resistance2 = UNDEFINED
resistance1 = UNDEFINED
p = UNDEFINED
support1 = UNDEFINED
support2 = UNDEFINED
support3 = UNDEFINED
M0 = UNDEFINED
M1 = UNDEFINED
M2 = UNDEFINED
M3 = UNDEFINED
M4 = UNDEFINED
M5 = UNDEFINED
ELSE
IF DAYOFWEEK[1] <> DAYOFWEEK THEN
prevmax = newmax
prevmin = newmin
prevclose = newclose
newmax = HIGH
newmin = LOW
newopen = OPEN
newclose = CLOSE
initialization = MAX(0, initialization - 1)
// initialization = 1 means that we are in the first entire day
// initialization = 0 means that we are in at least the second day
ELSE
newmax = MAX(newmax, HIGH)
newmin = MIN(newmin, LOW)
newclose = close
// uniquement apres les initialisations
IF initialization = 0 THEN
IF pivotmethod = 0 THEN
p = (prevmax + prevmin + prevclose) / 3
ELSIF pivotmethod = 1 THEN
p = (prevmax + prevmin + prevclose + newopen) / 4
ELSE
p = (prevmax + prevmin + newopen) / 3
ENDIF
resistance2 = p + (resistance1-support1)
resistance1 = (2 * p) - prevmin
P = p
support1 = (2 * p) - prevmax
support2 = p - (resistance1 - support1)
REM Formula for midpoints, S3 and R3 lines, remove comments to activate them and replace the "return line in the code with the commented return line below it.
resistance3 = prevmax + 2*(p-prevmin)
support3 = prevmin - 2*(prevmax-p)
M0 = (support3 + support2)/2
M1 = (support2 + support1)/2
M2 = (support1+p)/2
M3 = (resistance1+ p)/2
M4 = (resistance1+resistance2)/2
M5 = (resistance2+resistance3)/2
ENDIF
ENDIF
ENDIF
//RETURN resistance2 as "R2" , resistance1 as "R1" , P as "pivot" , support1 as "S1" , support2 as "S2"
Return M0 as "M0 Daily", M1 as "M1 Daily", M2 as "M2 Daily", M3 as "M3 Daily", M4 as "M4 Daily", M5 as "M5 Daily", resistance2 as "R2 Daily" , resistance1 as "R1 Daily" , P as "pivot Daily" , support1 as "S1 Daily" , support2 as "S2 Daily", resistance3 as "R3 Daily", support3 as "S3 Daily"
----------------------