Advertisement
Guest User

script for suddy boi

a guest
Jul 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. //@version=3
  2. study("Pivot Reversal Strategy Alerts V2", overlay=true)
  3.  
  4. // Inputs
  5. leftBars = input(4)
  6. rightBars = input(2)
  7.  
  8. // Calculate Pivot Points
  9. swh = pivothigh(leftBars, rightBars)
  10. swl = pivotlow(leftBars, rightBars)
  11.  
  12. swh_cond = not na(swh)
  13.  
  14. hprice = 0.0
  15. hprice := swh_cond ? swh : hprice[1]
  16.  
  17. swl_cond = not na(swl)
  18.  
  19. lprice = 0.0
  20. lprice := swl_cond ? swl : lprice[1]
  21.  
  22. // Signals
  23. long = crossover(high, hprice + syminfo.mintick)
  24. short = crossunder(low, lprice - syminfo.mintick)
  25.  
  26. last_signal = 0
  27.  
  28. long_final = long and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == -1)
  29. short_final = short and (nz(last_signal[1]) == 0 or nz(last_signal[1]) == 1)
  30.  
  31. last_signal := long_final ? 1 : short_final ? -1 : last_signal[1]
  32.  
  33. // Plotting
  34. plotshape(long_final, style = shape.arrowup, color = green, location = location.abovebar, text = "Long")
  35. plotshape(short_final, style = shape.arrowdown, color = red, location = location.belowbar, text = "Short")
  36.  
  37. plot(lprice, color = red)
  38. plot(hprice, color = green)
  39.  
  40. // Alerts
  41. alertcondition(long_final, "Pivot Long", "Pivot Long")
  42. alertcondition(short_final, "Pivot Short", "Pivot Short")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement