# SVE Piovots for Mobile
# Mobius
# V01.03.2022
def x = barNumber();
def nan = double.nan;
def h = high;
def l = low;
def c = close;
def day = getYYYYMMDD();
def today = if(day != day[1], x, today[1]);
def day2 = if(today != today[1], today[1], day2[1]);
def PH = if(x == highestAll(day2), h,
if(between(x, HighestAll(day2), highestAll(today)) and h > PH[1], h, PH[1]));
def PH1 = if isNaN(PH) then PH1[1] else PH;
def PL = if(x == highestAll(day2), l,
if(between(x, HighestAll(day2), highestAll(today)) and l < PL[1], l, PL[1]));
def PC = if(x == highestAll(today), c[1], PC[1]);
plot HH = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), PH, nan)), nan);
plot LL = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), PL, nan)), nan);
plot PP = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), (PH + PL + PC) / 3, nan)), nan);
plot R1 = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), 2 * PP - PL, nan)), nan);
plot R2 = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), PP + (PH - PL), nan)), nan);
plot R3 = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), 2 * PP + (PH - 2 * PL), nan)), nan);
plot S1 = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), 2 * PP - PH, nan)), nan);
plot S2 = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), PP - (PH - PL), nan)), nan);
plot S3 = if(x >= highestAll(today), highestAll(if(isNaN(c[-1]), 2 * PP - (2 * PH - PL), nan)), nan);
R3.SetDefaultColor(GetColor(5));
R2.SetDefaultColor(GetColor(5));
R1.SetDefaultColor(GetColor(5));
HH.SetDefaultColor(GetColor(5));
PP.SetDefaultColor(GetColor(1));
LL.SetDefaultColor(GetColor(6));
S1.SetDefaultColor(GetColor(6));
S2.SetDefaultColor(GetColor(6));
S3.SetDefaultColor(GetColor(6));
# End Code