As it turned out that DOpen, DClose etc. are not consistent with the trading session for the EUR/USD I am using this version of the pivot points. This results are also consistent with weekends and with the pivot points given on the website http://www.actionforex.com/ (for example). I don’t know, where I took the original code from (maybe a metatrader code), but I modified it a little bit, so the time when a “new day” starts is configurable.
defparam drawonlastbaronly = true
nd = 230000
if barindex = 0 then
init = 1
lastClose = undefined
lastHigh = undefined
lastLow = undefined
PP = undefined
Res1 = undefined
Res2 = undefined
Res3 = undefined
Sup1 = undefined
Sup2 = undefined
Sup3 = undefined
else
newDay = (Time[2] < nd AND Time[1] >= nd AND dayofweek <> 0) or (Time[2] < nd AND Time[1] >= nd and dayofweek[1] <> 0 and dayofweek[0] = 0)
if newDay then
if init = 1 then
lastHigh = High
lastLow = Low
init = 2
elsif init = 2 then
lastClose = Close[1]
PP = (lastClose + lastHigh + lastLow) / 3
hl = lastHigh - lastLow
Res1 = 2 * PP - lastLow
Sup1 = 2 * PP - lastHigh
Res2 = PP + hl
Sup2 = PP - hl
Res3 = Res1 + hl
Sup3 = Sup1 - hl
lastHigh = High
lastLow = Low
endif
endif
if init = 2 then
lastHigh = Max(lastHigh, High)
lastLow = Min(lastLow, Low)
endif
endif
return PP coloured(0,0,0) style(dottedline, 1) as "PP", Res1 coloured(200,200,0) style(dottedline, 1) as "R1", Res2 coloured(0,0,255) style(dottedline, 1) as "R2", Res3 coloured(255,0,0) style(dottedline, 1) as "R3", Sup1 coloured(200,200,0) style(dottedline, 1) as "S1", Sup2 coloured(0,0,255) style(dottedline, 1) as "S2", Sup3 coloured(255,0,0) style(dottedline, 1) as "S3"