#Ищет базу (или просто когда цена рядом), на Hi\Low дня, если сегодняшний Hi выше вчерашнего. #www.nyser.ru © def iDiff = 0.01; #максимальное отклонение для базы в центах def iDiff2 = 0.05; #максимальное расстояние до уровня ХайЛоу в центах def iLowest = lowest(low[0],4); def iHighest = highest(high[0],4); def iLow0 = low[0]; def iLow1 = low[1]; def iLow2 = low[2]; def iLow3 = low[3]; def iHigh0 = high[0]; def iHigh1 = high[1]; def iHigh2 = high[2]; def iHigh3 = high[3]; def iHighPrevDay = high(period = "DAY")[1]; def iLowPrevDay = Low(period = "DAY")[1]; def iHighDay = high(period = "DAY")[0]; def iLowDay = Low(period = "DAY")[0]; def bBaseLow = if ((iLow1-iLowest)<=iDiff) and ((iLow2-iLowest)<=iDiff) and ((iLow3-iLowest)<=iDiff) and ((iLow0-iLowest)<=iDiff) then 1 else 0; def bBaseHigh = if ((iHighest-iHigh1)<=iDiff) and ((iHighest-iHigh2)<=iDiff) and ((iHighest-iHigh3)<=iDiff) and ((iHighest-iHigh0)<=iDiff) then 1 else 0; def bNewDayHigh = if iHighDay >= iHighPrevDay then 1 else 0; def bNewDayLow = if iLowDay <= iLowPrevDay then 1 else 0; def bDiffLow = if close - iLowDay <= iDiff2 then 1 else 0; def bDiffHigh = if iHighDay - close <= iDiff2 then 1 else 0; plot bBase = if (bNewDayHigh and (bBaseLow or bBaseHigh)) then 1 else if (bNewDayLow and (bBaseLow or bBaseHigh)) then 2 else if (bNewDayHigh and bDiffHigh) then 3 else if (bNewDayLow and bDiffLow) then 4 else 100; AssignBackgroundColor (if (bBase == 1 or bBase == 3) then Color.LIGHT_GREEN else if (bBase == 2 or bBase == 4) then Color.LIGHT_RED else Color.black);