Advertisement
Maurizio-Ciullo

Indicatore Stocastico Per Strategie V5

May 16th, 2022
205
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 Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © Maurizio-Ciullo
  3.  
  4. //@version=5
  5. strategy(title='Indicatore Stocastico Per Strategie V5', overlay=true, precision = 2,
  6.      pyramiding=0,
  7.      initial_capital=150,
  8.      commission_type=strategy.commission.percent,
  9.      commission_value=0.1,
  10.      slippage=3,
  11.      default_qty_type=strategy.percent_of_equity,
  12.      default_qty_value=46)
  13.  
  14.  
  15. // Start Detecting Stocastico ///////////////////////////////////////////////////////
  16. periodK = input.int(14, title="%K Length", minval=1)
  17. smoothK = input.int(1, title="%K Smoothing", minval=1)
  18. periodD = input.int(3, title="%D Smoothing", minval=1)
  19. k = ta.sma(ta.stoch(close, high, low, periodK), smoothK)
  20. d = ta.sma(k, periodD)
  21. plot(k, title="%K", color=#2962FF)
  22. plot(d, title="%D", color=#FF6D00)
  23. h0 = hline(80, "Upper Band", color=#787B86)
  24. hline(50, "Middle Band", color=color.new(#787B86, 50))
  25. h1 = hline(20, "Lower Band", color=#787B86)
  26. fill(h0, h1, color=color.rgb(33, 150, 243, 90), title="Background")
  27. // End Detecting Stocastico ///////////////////////////////////////////////////////
  28.  
  29.  
  30. //entrata e uscita Long (stop/limit x prezzo) (loss/profit x ticks)
  31. if strategy.opentrades == 0 and k > 80
  32.     strategy.entry('operazioneLong', strategy.long, alert_message = "Open Long Position")
  33.    
  34.  
  35. if strategy.opentrades == 1  and k < 7
  36.     strategy.close(id='operazioneLong', alert_message = "Close Long Position")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement