//"FIBONACCI-INTRADAY"//
IF barindex = 0 THEN
initialization = 2 // we are in the middle of a day
L50 = undefined
L100 = undefined
L0 = undefined
L38 = undefined
L61 = undefined
L78 = undefined
L21 = undefined
L121 = undefined
L138 = undefined
L161 = undefined
LM121 = undefined
LM138 = undefined
LM161 = undefined
ELSE
IF dayofweek[1] <> dayofweek THEN
prevmax = newmax
prevmin = newmin
newmax = high
newmin = low
initialization = max(0, initialization - 1)
// initialization = 1 means we are on the first full day
// initialization = 0 means we are at least on the second day
ELSE
newmax = MAX(newmax, high)
newmin = MIN(newmin, low)
// only after initializations
IF initialization = 0 THEN
FRange = prevmax - prevmin
UseRange = FRange /100
L100 = prevmax
L21 = prevmin + (UseRange * 21.4)
L38 = prevmin + (UseRange * 38.2)
L50 = prevmin + (FRange / 2)
L61 = prevmin + (UseRange * 61.8)
L78 = prevmin + (UseRange * 78.6)
L0 = prevmin
L121 = prevmin + (UseRange * 121.4)
L138 = prevmin + (useRange * 138.2)
L161 = prevmin + (UseRange * 161.8)
LM121 = prevmax - (UseRange * 121.4)
LM138 = prevmax - (UseRange * 138.2)
LM161 = prevmax - (UseRange * 161.8)
ENDIF
ENDIF
ENDIF
RETURN L100 AS"100%", L78 As"78.6%", L61 AS"61.8%",L50 AS"50%", L38As"38.2%", L21 As"21.4%", L0 AS"0%", L121 AS"121.4%", L138AS"138.2%", L161 AS"161.8%", LM121 AS"L121.4%", LM138 AS"L138.2%", LM161 AS"L161.8%"