Guest User

Untitled

a guest
Jul 12th, 2023
153
0
Never
5
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.47 KB | None | 0 0
  1. // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © binancash
  3.  
  4. //@version=5
  5. indicator("ROBIN 1minute scalp", overlay=true)
  6.  
  7. //vwap start
  8. point_lb = 5
  9. point_rb = 5
  10. point_ph = ta.pivothigh(point_lb, point_rb)
  11. point_pl = ta.pivotlow(point_lb, point_rb)
  12.  
  13. var float running_ph = na
  14. var float running_pl = na
  15.  
  16. running_ph := running_ph
  17. running_pl := running_pl
  18.  
  19. if point_ph
  20. running_ph := point_ph
  21.  
  22. if point_pl
  23. running_pl := point_pl
  24.  
  25. var bool is_strong_buy = false
  26. var bool is_strong_sell = false
  27. if running_ph and ta.crossover(close, running_ph)
  28. is_strong_buy := true
  29. is_strong_sell := false
  30. if running_pl and ta.crossunder(close, running_ph)
  31. is_strong_buy := false
  32. if running_pl and ta.crossunder(close, running_pl)
  33. is_strong_sell := true
  34. is_strong_buy := false
  35. if running_pl and ta.crossover(close, running_pl)
  36. is_strong_sell := false
  37.  
  38. // logic buy sell improve start
  39. src = close
  40. di = (6 - 1.0) / 2.0 + 1.0
  41. c1 = 2 / (di + 1.0)
  42. c2 = 1 - c1
  43. c3 = 3.0 * (0.4 * 0.4 + 0.4 * 0.4 * 0.4)
  44. c4 = -3.0 * (2.0 * 0.4 * 0.4 + 0.4 + 0.4 * 0.4 * 0.4)
  45. c5 = 3.0 * 0.4 + 1.0 + 0.4 * 0.4 * 0.4 + 3.0 * 0.4 * 0.4
  46. var float i1 = na
  47. var float i2 = na
  48. var float i3 = na
  49. var float i4 = na
  50. var float i5 = na
  51. var float i6 = na
  52. i1 := c1 * src + c2 * nz(i1[1])
  53. i2 := c1 * i1 + c2 * nz(i2[1])
  54. i3 := c1 * i2 + c2 * nz(i3[1])
  55. i4 := c1 * i3 + c2 * nz(i4[1])
  56. i5 := c1 * i4 + c2 * nz(i5[1])
  57. i6 := c1 * i5 + c2 * nz(i6[1])
  58.  
  59. Cto = -0.4 * 0.4 * 0.4 * i6 + c3 * i5 + c4 * i4 + c5 * i3
  60. //bfrC = Cto > nz(Cto[1]) ? raise : Cto < nz(Cto[1]) ? fall : na
  61. ema3 = ta.ema(close, 3)
  62.  
  63. var bool is_cross_up = false
  64. var bool is_cross_down = false
  65. if ta.crossover(ema3, Cto)
  66. is_cross_up := true
  67. is_cross_down := false
  68. if ta.crossunder(ema3, Cto)
  69. is_cross_down := true
  70. is_cross_up := false
  71.  
  72. //condition Long & Short
  73. long = (close > Cto and close[1] < Cto[1] and close > close[1] or close[1] > Cto[1] and close > close[1] and close [1] < close[2] and close > ema3) ? true : false
  74. profit_long = close < close[1] and low < ema3 and close[1] > ema3[1] and close[2] > ema3[2]
  75. //var int trend = 0
  76.  
  77. short = (close < Cto and close[1] > Cto[1] and close < close[1] or close[1] < Cto[1] and close < close[1] and close [1] > close[2] and close < ema3) ? true : false
  78. profit_short = close > close[1] and high > ema3 and close[1] < ema3[1] and close[2] < ema3[2]
  79.  
  80. // logic buy sell improvate end
  81.  
  82. rsi = ta.rsi(close, 3)
  83.  
  84.  
  85.  
  86.  
  87.  
  88. ema48 = ta.wma(close, 48)
  89. ema11 = ta.wma(close, 11)
  90. ema200 = ta.wma(close, 200)
  91.  
  92. close10 = request.security(symbol=syminfo.tickerid, timeframe="12", expression=close, lookahead=barmerge.lookahead_on)
  93.  
  94. wma10_11 = ta.wma(close, 4)
  95. wma_10_11 = request.security(symbol=syminfo.tickerid, timeframe="12", expression=wma10_11, lookahead=barmerge.lookahead_on)
  96.  
  97.  
  98. wma10_48 = ta.wma(close, 9)
  99. wma_10_48 = request.security(symbol=syminfo.tickerid, timeframe="12", expression=wma10_48, lookahead=barmerge.lookahead_on)
  100.  
  101.  
  102. var bool cross_up_wma_10 = false
  103. var bool cross_down_wma_10 = false
  104. if ta.crossover(wma_10_11, wma_10_48)
  105. cross_up_wma_10 := true
  106. cross_down_wma_10 := false
  107. if ta.crossunder(wma_10_11, wma_10_48)
  108. cross_up_wma_10 := false
  109. cross_down_wma_10 := true
  110.  
  111. up10m = false
  112. if close10 > wma_10_11
  113. up10m := true
  114.  
  115. ////logic volume start
  116. x = input.float(3.1, title="Factor For Breakout Candle")
  117. red = #ff848a //#ff848a // #FA8072 // #323433 // #ff848a
  118. green = #8cffe5 // #8cffe5 // #6DC066 // #80aebd // #8cffe5
  119.  
  120. // Basic Volume Calcs //
  121. bull = close>open?volume:0
  122. bear = open>close?volume:0
  123.  
  124.  
  125. // BEAR Moving Average Calculation
  126. bullma = ta.sma(bull, 14)
  127.  
  128. // BEAR Moving Average Calculation //
  129. bearma = ta.sma(bear, 14)
  130.  
  131. // ma dif //
  132. vf_dif = bullma-bearma
  133. vf_absolute = vf_dif > 0 ? vf_dif : vf_dif * (-1)
  134.  
  135. // Volume Spikes //
  136. var bool gsig = false
  137. var bool rsig = false
  138. if ta.crossover(bull, bullma*x)
  139. gsig := true
  140. rsig := false
  141. if ta.crossover(bear, bearma*x)
  142. rsig := true
  143. gsig := false
  144.  
  145. // Color Calcs //
  146. vdClr = vf_dif > 0 ? true : false
  147. vClr = close>open ? true:false
  148.  
  149.  
  150. ////logic volume end
  151.  
  152. // super trend start
  153. cci_period = 28
  154. cci = ta.cci(close, cci_period)
  155. ML = 0
  156.  
  157. Factor=3
  158. Pd=3
  159. f_supertrend(Factor, Pd) =>
  160.  
  161. Up=hl2-(Factor*ta.atr(Pd))
  162. Dn=hl2+(Factor*ta.atr(Pd))
  163.  
  164. TrendUp = 0.0
  165. TrendUp := cci[1] > ML ? math.max(Up,TrendUp[1]) : Up
  166. TrendDown = 0.0
  167. TrendDown := cci[1]< ML ? math.min(Dn,TrendDown[1]) : Dn
  168. Trend = 0.0
  169. Trend := cci > ML ? 1: cci < ML ? -1: nz(Trend[1],1)
  170. Tsl = Trend==1? TrendUp: TrendDown
  171.  
  172. Tsl
  173.  
  174. st_tsl = f_supertrend(Factor, Pd)
  175.  
  176. buy= close >= st_tsl
  177. sell= close < st_tsl
  178. buy1= ta.barssince(buy)
  179. sell1 = ta.barssince(sell)
  180. buy_trend = buy1[1] > sell1[1] ? true : false
  181.  
  182. buy2= ta.barssince(sell)
  183. sell2 = ta.barssince(buy)
  184. sell_trend = buy2[1] > sell2[1] ? true : false
  185. var bool is_buy = false
  186. var bool is_sell = false
  187. if sell_trend
  188. is_sell := true
  189. is_buy := false
  190. if buy_trend
  191. is_sell := false
  192. is_buy := true
  193. // super trend end
  194.  
  195. // ema cross start
  196.  
  197. oc = math.abs(open[1]-close[1])
  198. hl = math.abs(high[1]-low[1])
  199. ochl = (oc-hl)/hl
  200. ll = (low[1]-low[2])/low[2]
  201. crossUpWMA11 = ta.crossover(ema11, ema48)
  202. crossDownWMA11 = ta.crossunder(ema11, ema48)
  203. var bool crossup11_48 = false
  204. var bool crossdown11_48 = false
  205. var int cnt_out_up = 0
  206. if crossUpWMA11
  207. crossup11_48 := true
  208. crossdown11_48 := false
  209. cnt_out_up := 0
  210. if crossDownWMA11
  211. crossup11_48 := false
  212. crossdown11_48 := true
  213. cnt_out_up := 0
  214. is_br = open[2] < close[2] and open[1] < close[1] and close < open and close[2] < close[1] and close[1] > close and ochl < 0.3 and (low[3] < low[2] and low[2] < low[1])
  215. if is_br
  216. cnt_out_up := cnt_out_up + 1
  217.  
  218. is_out_up = false
  219. if cnt_out_up>2
  220. is_out_up := true
  221. cnt_out_up := 0
  222.  
  223. // ema cross end
  224.  
  225.  
  226. // trend strong start
  227. wma13 = ta.wma(close, 13)
  228.  
  229.  
  230. wma48 = ta.wma(close, 48)
  231.  
  232.  
  233. wma200 = ta.wma(close, 200)
  234.  
  235.  
  236. crossUpWMA13 = ta.crossover(close, wma13)
  237. crossDownWMA13 = ta.crossunder(close, wma13)
  238. crossUpWMA48 = ta.crossover(close, wma48)
  239. crossDownWMA48 = ta.crossunder(close, wma48)
  240. crossUpWMA200 = ta.crossover(close, wma200)
  241. crossDownWMA200 = ta.crossunder(close, wma200)
  242.  
  243. crossUpWMA13_48 = ta.crossover(wma13, wma48)
  244. crossDownWMA13_48 = ta.crossunder(wma13, wma48)
  245. crossUpWMA48_200 = ta.crossover(wma48, wma200)
  246. crossDownWMA48_200 = ta.crossunder(wma48, wma200)
  247.  
  248. var price_wmacrossup_arr = array.new_float()
  249. var price_wmacrossdown_arr = array.new_float()
  250.  
  251. if crossUpWMA48_200
  252. price_wmacrossdown_arr := array.new_float()
  253. array.push(price_wmacrossup_arr, close)
  254. else if crossDownWMA48_200
  255. price_wmacrossup_arr := array.new_float()
  256. array.push(price_wmacrossdown_arr, close)
  257.  
  258. var bool isUpTrend = false
  259. var bool isDownTrend = false
  260.  
  261. if crossUpWMA13 and isUpTrend == false
  262. isUpTrend := true
  263. isDownTrend := false
  264. else if crossUpWMA48 and isUpTrend == false
  265. isUpTrend := true
  266. isDownTrend := false
  267. else if crossUpWMA200 and isUpTrend == false
  268. isUpTrend := true
  269. isDownTrend := false
  270.  
  271. if crossDownWMA13 and isDownTrend == false
  272. isUpTrend := false
  273. isDownTrend := true
  274. else if crossDownWMA48 and isDownTrend == false
  275. isUpTrend := false
  276. isDownTrend := true
  277. else if crossDownWMA200 and isDownTrend == false
  278. isUpTrend := false
  279. isDownTrend := true
  280.  
  281. var int trendUp = 0
  282. var int trendDown = 0
  283.  
  284. if isUpTrend
  285. if crossUpWMA13_48
  286. trendUp := 1
  287. trendDown := 0
  288. if crossUpWMA48_200
  289. trendUp := 2
  290. trendDown := 0
  291.  
  292. if isDownTrend
  293. if crossDownWMA13_48
  294. trendUp := 0
  295. trendDown := 1
  296. if crossDownWMA48_200
  297. trendUp := 0
  298. trendDown := 2
  299. // trend strong end
  300.  
  301. bottomsupport = running_pl and close > running_pl and close > close[1] and rsi > rsi[1] + 8
  302.  
  303. bigdrop = rsi + 8 < rsi[1] and close > ema48 and running_ph and close < running_ph
  304.  
  305.  
  306. longConditionClassic = up10m and buy_trend and ( close*1.05 > wma13 and rsi > rsi[1] + 6 or rsi > rsi[1] + 8 and long or is_cross_up and bottomsupport and is_strong_buy or bottomsupport)
  307.  
  308. shortConditionClassic = not up10m and (close*0.94 < wma13 and rsi + 8 < rsi[1] or rsi + 8 < rsi[1] and short or is_br or bigdrop and is_strong_sell)
  309.  
  310. var int buysignal = 0
  311. var int sellsignal = 0
  312.  
  313. if longConditionClassic
  314. buysignal := 1
  315. sellsignal := 0
  316. else if shortConditionClassic
  317. buysignal := 0
  318. sellsignal := 1
  319.  
  320. longCondition = longConditionClassic and sellsignal[1]
  321. shortCondition = shortConditionClassic and buysignal[1]
  322.  
  323. // Plotting the indicators
  324. plotshape(longCondition , text='buy', style=shape.labelup, location=location.belowbar, color=color.green, textcolor=color.white, offset=0, size=size.tiny)
  325. plotshape(shortCondition , text='sell', style=shape.labeldown, location=location.abovebar, color=color.red, textcolor=color.white, offset=0, size=size.tiny)
  326.  
  327.  
  328. // exit long when has a short signal and otherwise
  329. closelong = shortCondition or ((rsi > 70 ) and high[2] < high[1] and high[1] > high or not up10m and (trendDown > 1 or profit_long or sell_trend or bigdrop and not is_cross_up or is_out_up ))
  330. closeshort = longCondition or up10m and (trendUp > 1 or profit_short or buy_trend or bottomsupport and not is_cross_down)
  331.  
  332. alertcondition(longCondition == 1 or shortCondition == 1 ,title="Buy/Sell",message="Buy/Sell")
  333.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment