Advertisement
Maurizio-Ciullo

Bot PURE MORNING BINANCE ALPINE/USDT 30M SOLO LONG

Feb 18th, 2023
1,112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // This source code is subject to the terms of the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
  2. // © TheSocialCryptoClub
  3.  
  4. //https://it.tradingview.com/script/OUrwlvNg/
  5. //Vedi specifiche e uso nella cartella bot utenti
  6.  
  7. //@version=5
  8. strategy("PURE MORNING", overlay=true, pyramiding=1,
  9.          initial_capital=1000, default_qty_type=strategy.cash,
  10.          default_qty_value=1000,
  11.          slippage=2, commission_type=strategy.commission.percent,commission_value=0.075
  12.          )
  13.  
  14. //------------------------------
  15. // Indicators
  16. //------------------------------
  17.  
  18. rma=ta.rma(close, 60)
  19. mfi=ta.mfi(close, 10)
  20. rsi=ta.rsi(close, 14)
  21. atr7= ta.atr(7)
  22. ema60=ta.ema(close,60)
  23.  
  24. plot(ema60,"EMA 60", color.new(color.aqua,0))
  25.  
  26. //------------------------------
  27. // Doji settings
  28. //------------------------------
  29. //-----------------------------------------------MORNING DOJI STAR CODE
  30. range1= high - low
  31. tolerance = input.float(defval=0.09, title="MDS Tolerance",group= "DOJI SETTINGS", minval=0.01, maxval=1, step=.01)/100
  32.  
  33. candle1 = math.abs (close[2] - open[2]) /range1[2] > .6 and close[2] < open[2]
  34. candle2 = ((open[1] > close[1] and open[1] < close[1]*(1+tolerance)) or (open[1] < close[1] and open[1] > close[1]*(1-tolerance)) and close [1]<close[2]+range1[2])
  35. candle3 = close > open and close > (close[2]+range1[2])
  36.  
  37. MDS = candle1 and candle2 and candle3
  38.  
  39. plotshape(MDS and close > ema60, text="MD", textcolor=color.yellow, offset=-1, location=location.abovebar, color=color.green, style=shape.triangleup)
  40. plotshape(MDS and close < ema60, text="MD", textcolor=color.olive, offset=-1, location=location.belowbar, color=color.red, style=shape.triangledown)
  41.  
  42. //------------------------------------------------DOJI CODE
  43.  
  44. tolerance1= input.float(defval=0.05, title="DOJI Tolerance",group= "DOJI SETTINGS", minval=0.01, maxval=1, step=.01)/100
  45. Is_OC_Equal= (open > close and open < close*(1+tolerance1)) or (open < close and open > close*(1-tolerance1))
  46.  
  47. plotshape(Is_OC_Equal and close < ema60, text="D", textcolor=color.red, location=location.belowbar, color=color.red)
  48. plotshape(Is_OC_Equal and close > ema60, text="D", textcolor = color.green, location=location.abovebar, color=color.green)
  49.  
  50. //------------------------------
  51. // Entry Long
  52. //------------------------------
  53.  
  54. el_cond= Is_OC_Equal and close > ema60
  55. el_cond_02= MDS and close > ema60
  56.  
  57. mess = "!buy " + syminfo.ticker // Executor command to buy automatically
  58.  
  59. if el_cond
  60.     strategy.entry ("EL", strategy.long ,alert_message = mess,comment = "EL cond 1")
  61.  
  62. plotshape(el_cond and strategy.position_size == 0 , "el_long", shape.circle, color=color.green)
  63.  
  64. if el_cond_02      
  65.     strategy.entry ("EL", strategy.long ,alert_message = mess,comment = "EL cond 2" )
  66.  
  67. plotshape(el_cond_02 and strategy.position_size == 0 , "el_long_02", shape.circle, color=color.green)
  68.  
  69. //------------------------------
  70. //Exit Long TP - SL
  71. //------------------------------
  72.  
  73. sl_len             = input.int(100, "Stop Length",group="EXIT LONG")
  74. sl_type_percent    = input.bool(false,"SL type percent",group="EXIT LONG")
  75. xl_sl_percent      = input.float (2, step=0.5, title="Stop Loss",group="EXIT LONG")
  76. xl_tp_percent      = input.float(9, step=0.5, title="Take Profit",group="EXIT LONG")
  77.  
  78. xl_sl_price = strategy.position_avg_price * (1-xl_sl_percent/100)
  79. xl_tp_price = strategy.position_avg_price * (1+xl_tp_percent/100)
  80.  
  81. if sl_type_percent == false
  82.     xl_sl_price := ta.lowest (low, sl_len)
  83.  
  84. //------------------------------
  85. //Trailing stop
  86. //------------------------------
  87.  
  88. xl_ts_percent      = input.float(1,step=0.5, title= "Trailing theshold",group="TRAILING STOP")
  89. xl_to_percent      = input.float(0.5, step=0.5, title= "Trailing offset",group="TRAILING STOP")
  90.  
  91. xl_ts_tick = xl_ts_percent * close/syminfo.mintick/100
  92. xl_to_tick = xl_to_percent * close/syminfo.mintick/100
  93.  
  94. mess_sell = "!sell " + syminfo.ticker // Executor command to sell automatically
  95.  
  96. strategy.exit("XL+SL/TP", "EL", stop=xl_sl_price, limit=xl_tp_price, trail_points=xl_ts_tick, trail_offset=xl_to_tick,comment_loss= "STOP", comment_profit = "PROFIT",comment_trailing = "TS", alert_message = mess_sell)
  97.  
  98. //------------------------------
  99. // Conditional close on MFI
  100. //------------------------------
  101.  
  102. xl_cond= ta.crossover(mfi, 90)
  103.  
  104. if xl_cond
  105.     strategy.close("XL", alert_message = mess_sell)
  106.  
  107. plotshape(xl_cond, "xl_cond", shape.circle, color=color.red)
  108.  
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement