Dark_Coder

ENVOLVENTE_VIP_strategy_v1

Jan 9th, 2022
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 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. // © Dark_Trader-x01
  3.  
  4. //@version=4
  5.  
  6. //########################################################################################################//
  7. strategy(title="ENVOLVENTE_VIP_strategy_v1", overlay=true, default_qty_type=strategy.cash, default_qty_value=1000, initial_capital=1000, currency=currency.USD)
  8. //########################################################################################################//
  9.  
  10.  
  11. //########################################################################################################//
  12. // DECLARACION DE VARIABLES
  13. bool env_BUY = false
  14. bool env_SELL = false
  15.  
  16. var float sl_long = na
  17. var float sl_short = na
  18. var float tp_long = na
  19. var float tp_short = na
  20. //########################################################################################################//
  21.  
  22.  
  23. //########################################################################################################//
  24. // FUNCIONES
  25. longstop = lowest(low, 2)
  26. shortstop = highest(high, 2)
  27. //########################################################################################################//
  28.  
  29.  
  30. //########################################################################################################//
  31. // VELA ENVOLVENTE VIP ALCISTA
  32. if (close > open) and (open[1] > close[1]) and (close > open[1]) and (open < close[1])
  33. env_BUY := true
  34.  
  35. // VELA ENVOLVENTE VIP BAJISTA
  36. if (open > close) and (close[1] > open[1]) and (open > close[1]) and (close < open[1])
  37. env_SELL := true
  38. //########################################################################################################//
  39.  
  40.  
  41. //########################################################################################################//
  42. // STOP-LOSS y TAKE-PROFIT
  43. /// ALCISTA
  44. if env_BUY and strategy.position_size == 0
  45. sl_long := longstop
  46. tp_long := close
  47.  
  48. /// BAJISTA
  49. if env_SELL and strategy.position_size == 0
  50. sl_short := shortstop
  51. tp_short := close
  52. //########################################################################################################//
  53.  
  54.  
  55. //########################################################################################################//
  56. // ESTRATEGIA ALCISTA
  57. strategy.entry(id="LONG", long=true, when=env_BUY)
  58. strategy.exit(id="LONG_EXIT", from_entry="LONG", stop=sl_long) // STOP-LOSS
  59. strategy.close(id="LONG", when=(close > tp_long) or (open > tp_long)) // TAKE-PROFIT
  60.  
  61. // ESTRATEGIA BAJISTA
  62. strategy.entry(id="SHORT", long=false, when=env_SELL)
  63. strategy.exit(id="SHORT_EXIT", from_entry="SHORT", stop=sl_short) // STOP-LOSS
  64. strategy.close(id="SHORT", when=(close < tp_short) or (open < tp_short)) // TAKE-PROFIT
  65. //########################################################################################################//
  66.  
  67.  
  68. //########################################################################################################//
  69. // PLOTS
  70. plotshape(env_BUY, style=shape.arrowup, text="env_BUY", location=location.abovebar, color=color.green)
  71. plotshape(env_SELL, style=shape.arrowdown, text="env_SELL", location=location.belowbar, color=color.red)
  72. //########################################################################################################//
  73.  
Advertisement
Add Comment
Please, Sign In to add comment