Скрипт вчерашних экстремумов дня

serafim

Житель Разулы
Команда форума
СПОНСОР ♥
Регистрация
25 Апр 2016
Сообщения
18.664
Симпатии
6.107
#1
Утащил из одной конторы интересный скрипт для биржы, который ищет базы на круглых уровнях 50,100 центов или на вчерашних крайних точек.




def iDiff = 0.01; #максимальное отклонение в центах
def iBars = 4; #число баров для просмотра
def iLowest = lowest(low,iBars);
def iHighest = highest(high,iBars);
def iHiPrevDay = high(period = «DAY»)[1];
def iLowPrevDay = Low(period = «DAY»)[1];
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 iFigureLow = fold FLbar = 1 to iBars+1 with FLsumm do if (low[FLbar] == (Floor(low[FLbar]*2))/2) then FLsumm+1 else FLsumm;
def iFigureHigh = fold FHbar = 1 to iBars+1 with FHsumm do if (high[FHbar] == (Ceil(high[FHbar]*2))/2) then FHsumm+1 else FHsumm;
def iDayLow = fold DLbar = 0 to iBars with DLsumm do if (Low[DLbar] == iHiPrevDay) then DLsumm+1 else DLsumm;
def iDayHigh = fold DHbar = 0 to iBars with DHsumm do if (High[DHbar] == iLowPrevDay) then DHsumm+1 else DHsumm;
plot bBase = if (bBaseLow and iFigureLow ) then 1 else if (bBaseHigh and iFigureHigh ) then 2 else if (bBaseLow and iDayLow) then 3 else if (bBaseHigh and iDayHigh) 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);
 
Сверху