#Ищет базы из Х свечей, если перед базой есть тренд за N свечей, учитывая общее направление. #Cнять галочку Include Extended Session #www.nyser.ru © def iDiff = 0.01; #максимальное отклонение в центах def iBars = 4; #число баров для просмотра базы def iBars2 = 4; #число баров для просмотра тренда def iLowest = lowest(low,iBars); def iHighest = highest(high,iBars); def bBaseLow = fold Lbar = 0 to iBars with Lsumm=1 do if ((low[Lbar]-iLowest)<=iDiff) then Lsumm*1 else Lsumm*0; def bBaseHigh = fold Hbar = 0 to iBars with Hsumm=1 do if ((iHighest-high[Hbar])<=iDiff) then Hsumm*1 else Hsumm*0; def bTrendUp = fold TUbar = iBars to iBars2+iBars with TUsumm=1 do if (close[TUbar] - open[TUbar]>0) then TUsumm*1 else TUsumm*0; def bTrendDown = fold TDbar = iBars to iBars2+iBars with TDsumm=1 do if (close[TDbar] - open[TDbar]<0) then TDsumm*1 else TDsumm*0; def bChangeUP = if (close[0]-close(getSymbol(),aggregationPeriod.DAY)[0]>=0) then 1 else 0; def bChangeDOWN = if (close[0]-close(getSymbol(),aggregationPeriod.DAY)[0]<0) then 1 else 0; plot bBase = if (bBaseLow and bChangeUP and bTrendUp) then 1 else if (bBaseHigh and bchangeDOWN and bTrendDown) 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 > 0 and bBase < 100 ) then Color.black else Color.CURRENT);