// Created by Роман версия 2
// Candle хай и лоу labels
study(title = "Candles H&L label", overlay = true)
//N= input(10, minval=2, title="Количество свечей") //определяется кол-во свечей для контроля
////////////////////////////////////////////////////////////////////////
// сравненительный анализ максимумов и минимумов соседних свечей
data2=(high[1]==high and high[1]!=max(open[1],close[1]) and high!=max(open,close)) // задает параметр сравнения ближайших максимальных значений
plotshape(data2, color=red, style=shape.triangledown)
data7=(high[2]==high and high[2]!=max(open[2],close[2]) and high!=max(open,close)) // задает параметр сравнения ближайших максимальных значений
plotshape(data7, color=red, style=shape.cross)
data4=(low[1]==low and low[1]!=min(open[1],close[1]) and low!=min(open,close)) // задает параметр сравенения ближайших минимальных значений
plotshape(data4, location=location.belowbar, color=green, style=shape.triangleup)
data9=(low[2]==low and low[2]!=min(open[2],close[2]) and low!=min(open,close)) // задает параметр сравенения ближайших минимальных значений
plotshape(data9, location=location.belowbar, color=green, style=shape.cross)
//data6=(close[1] > open[1] and open > close and open <= close[1] and open[1] <= close and open - close < close[1] - open[1] )
//plotshape(data6, title= "Be H", color=red, style=shape.arrowdown, text="Медвежий Харами")
//data7=(open[1] > close[1] and close > open and close <= open[1] and close[1] <= open and close - open < open[1] - close[1] )
//plotshape(data7, title= "Bu H", location=location.belowbar, color=lime, style=shape.arrowup, text="BullishnHarami")
////////////////////////////////////////////////////////////////////////////////////////
// sma
plot(sma(low, 7)) // рисует SMA нижнюю
plot(sma(high, 7)) // рисует SMA верхнюю
///////////////////////////////////////////////////////
// точки пивот
// leftBars = input(20, minval=2, title="Свечи слева")
// rightBars=input(20, minval=2, title="Свечи справа")
// ph = pivothigh(leftBars, rightBars)
//plot(ph, style=cross, linewidth=2, color= red, offset=-rightBars)
////////////////////////////////////////////////////////
// ema
len = input(10, minval=1, title="Length")
src = input(close, title="Source")
lng = input(15, minval=3, title="количество баров" )
out = ema(src, len)
//plot(out, title="EMA", color=red)
last8h = highest(close, 8)
lastl8 = lowest(close, 8)
//plot(last8h, color=red, linewidth=1)
//plot(lastl8, color=green, linewidth=1)
bearish = cross(close,out) == 1 and close[1] > close and close[16] > close
bullish = cross(close,out) == 1 and close[1] < close and close[16] < close
// plotshape(bearish, color=red, style=shape.arrowdown, text="Sell", location=location.abovebar)
// plotshape(bullish, color=green, style=shape.arrowup, text="Buy", location=location.belowbar)
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Медвежий разворот
data11=(open[3]<=close[3] and open[2]<close[2] and open[1]<close[1] and close[3]==open[2] and close[2]==open[1] and close[1]==open and close<low[2] ) // задает параметр медвежьего разворота
plotshape(data11, color=red, style=shape.arrowdown, text="BEAR SELL", location=location.abovebar)
// Бычий разворот
data21=(open[3]>=close[3] and open[2]>close[2] and open[1]>close[1] and close[3]==open[2] and close[2]==open[1] and close[1]==open and close>high[2] ) // задает параметр бычьего разворота
plotshape(data21, color=green, style=shape.arrowup, text="BULL BUY", location=location.belowbar)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////