J’ai trouvé ce code sur prorealcode.com
Une excellente initiative, car ici on prend en compte les points pivot en fonction des horaires de nouvelle session, que l’on peut manuellement définir.
« nd » signifie en effet « New Day ».
si nd = 230000, cela signifie que la journée commence à 23 heures.
Voici le code de l’INDICATEUR (à insérer au niveau du prix)
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"