How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Feature Request FAQ Help & Wiki Twitter

# ForNataly

75 0
Test on audcad             for 25 min on tf5
study(title="ForNataly", shorttitle= "ForNataly", overlay=true)

bf_period = 10 //период Болли
bf_period20 = 40 //период Болли
bf_stddev = 2
bf_profit = 0.1
bf_rsi = 40
bf_rsi_inner = 0

bf_middle = sma(close, bf_period)
bf_20 = sma(close, bf_period20)
rsi_ = rsi(close, 14)
st = stoch(close, high, low, 25)
bf_top = bf_middle + (stdev(close, bf_period) * bf_stddev)
bf_bottom = bf_middle - (stdev(close, bf_period) * bf_stddev)
bf_short_exit = bf_short_entry - bf_height

bf_long_exit = bf_long_entry + bf_height

bf_long = close < bf_middle ? (close > bf_bottom ? true : false) : false
bf_short = close > bf_middle ? (close < bf_top ? true : false) : false

bf_lowest = low == lowest(bf_period / 2) ? ( low < bf_bottom ? true : false ) : false
bf_highest = high == highest(bf_period / 2) ? ( high > bf_top ? true : false ) : false

bf_rsi_long = rsi(close, 20) > (50 + bf_rsi_inner) ? (rsi(close, 20) < (50 + bf_rsi) ? true : false) : false
bf_rsi_short = rsi(close, 20) < (50 - bf_rsi_inner) ? (rsi(close, 20) > (50 - bf_rsi) ? true : false) : false
bf_go_long = bf_long ? ( bf_lowest ? ( bf_long_exit < (bf_middle - bf_spread) ? (bf_rsi_short ? true : false) : false ) : false ) : false
bf_go_short = bf_short ? ( bf_highest ? ( bf_short_exit > (bf_middle + bf_spread) ? (bf_rsi_long ? true : false) : false ) : false ) : false
bf_enter = bf_go_long ? bf_long_entry : ( bf_go_short ? bf_short_entry : bf_enter[1] )
bf_exit = bf_go_long ? bf_long_exit : ( bf_go_short ? bf_short_exit : bf_exit[1] )
bf_stop = bf_go_long ? bf_long_stop : ( bf_go_short ? bf_short_stop : bf_stop[1] )
//plot(bf_enter == bf_enter[bf_period] ? na : bf_enter, title="Entry", color=blue, style=circles, linewidth=2)
StochAndRSIup = rsi_>70 and st >80
StochAndRSIdown = rsi_ <30 and st <20

barcolor(StochAndRSIup   ? lime : na)
barcolor(StochAndRSIdown  ? yellow : na)

//////////////////////////////////////////////////////////////////////
//Считаем стохастика
len = 14
smoothK = 3
smoothD = 3
upLine = 90
lowLine = 20

sbc = true
sbh = false
sch = false
sl = true
sac = false
sacl = false

//Stoch formula
k = sma(stoch(close, high, low, len), smoothK)
d = sma(k, smoothD)

//Necessary for Highlight Bars
aboveLine = k > upLine ? 1 : 0
belowLine = k < lowLine ? 1 : 0

//Only Necessary if you want you want Stochastic Croses
//Definition for Cross when Above High-Low lines
crossUp = (k[1] < d[1] and k[1] < lowLine[1]) and (k > d)  ? 1 : 0
crossDn = (k[1] > d[1] and k[1] > upLine[1]) and (k < d) ? 1 : 0

//Only Necessary if you want you want Stochastic Croses
//Definition for Cross that doesn't have to be above or below High and Low line.
crossUpAll = (k[1] < d[1] and k > d) ? 1 : 0
crossDownAll = (k[1] > d[1] and k < d) ? 1 : 0

overBought() => sbc and aboveLine
overSold() => sbc and belowLine

resStochUp = sl and crossUp
resStochDown = sl and crossDn

//Теперь надо отсечь вход на доджи.
//Считаем доджи свечу
//upMax = high
//upClose = close
//upMin = low
//upOpen = open

//isDoji = ( (upClose-upOpen)  <  ((upMax - upMin)/3) ) and (upMax > upClose and upMin < upOpen)  and (  ((upMax-upMin) / (upClose-upOpen)) > 50)
//isUpDoji =(upMax > upClose and upMin < upOpen) and (  ((upMax-upMin) / (upClose-upOpen)) > 50)
//plotchar(isDoji ? 1 : na, title="Dodji", char='D', location=location.abovebar, color=blue, transp=0, offset=0)

finalUp = StochAndRSIup or  resStochUp
finalDown = resStochDown or StochAndRSIdown

plotarrow(finalUp ? crossUp : na, title="Строгое соответствие на покупку", colorup=blue, maxheight=30, minheight=30, transp=0, offset=0)
plotchar(finalUp ? crossUp : na, title="Buy Entry", offset=0, char='К', location=location.abovebar, color=lime, transp=0, offset=0)

plotarrow(finalDown ? crossDn : na, title="Строгое соответствие на продажу", colorup=blue, maxheight=30, minheight=30, transp=0, offset=0)
plotchar(finalDown ? crossDn : na, title="Short Entry", offset=0, char='П', location=location.abovebar, color=red, transp=0, offset=0)

//plotchar(sacl and crossUpAll ? crossUpAll : na, title="Слабачок на продажу", char='↓', location=location.belowbar, color=lime, transp=0, offset=0)
//plotchar(sacl and crossDownAll ? crossDownAll : na, title="Слабачок на покупку", char='↑', location=location.abovebar, color=red, transp=0, offset=0)
///////////////////////////////////////////////////////////////////////
//plotchar(finalUp ? crossUp : na, title="Строгое соответствие на покупку", char='↑', location=location.belowbar, color=lime, transp=0, offset=0)
//plotchar(finalDown ? crossDn : na, title="Строгое соответствие на продажу", char='↓', location=location.abovebar, color=red, transp=0, offset=0)

//plotchar(StochAndRSIup ? 1 : na, title="На продажу по RSI", char='↓', location=location.abovebar, color=blue, transp=0, offset=0)
//plotchar(StochAndRSIdown ? 1 : na, title="На покупку по RSI", char='↑', location=location.abovebar, color=blue, transp=0, offset=0)

rsi_slow = input(14, title="Slow RSI")
rsi_fast = input(3, title="Fast RSI")
rs_s =rsi(close,rsi_slow)
rs_f = rsi(close,rsi_fast)

final_rsi = (rs_s == rs_f) ? 1:0
plot(rs_s == rs_f  ? close + rs_s/100000 : na, style=circles)


United States
United Kingdom
India
España
France
Italia
Polska
Brasil
Россия
Türkiye
Indonesia

한국
Home Stock Screener Forex Signal Finder Economic Calendar How It Works Chart Features House Rules Moderators For the WEB Widgets Stock Charting Library Priority Support Feature Request Blog & News FAQ Help & Wiki Twitter