1) BASE
def iDiff = 0.01;
def iBars = 4;
def iLowest = lowest(low,iBars);
def iHighest = highest(high,iBars);
def bBaseLow = fold Lbar = 0 to iBars with Ls=1 do if ((low[Lbar]-iLowest)<=iDiff) then Ls*1 else Ls*0;
def bBaseHigh = fold Hbar = 0 to iBars with Hs=1 do if ((iHighest-high[Hbar])<=iDiff) then Hs*1 else Hs*0;
plot bBase = if bBaseLow then 1 else if bBaseHigh then 2 else 100;
AssignBackgroundColor (if (bBase == 1) then Color.LIGHT_GREEN else if (bBase == 2) then Color.LIGHT_RED else Color.black);
bBase.AssignValueColor (if bBase <> 100 then Color.black else Color.CURRENT);
Дальше