xmd79

Top and bottom Hunter

May 27th, 2023
518
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. //@version=5
  2. indicator("Top and bottom Hunter", overlay=true)
  3.  
  4. // Fibonacci Levels
  5. fib_0 = input.float(0.382, "Fib Level 0")
  6. fib_1 = input.float(0.618, "Fib Level 1")
  7.  
  8. // Calculate Fibonacci levels
  9. fib_range = ta.highest(high, 2) - ta.lowest(low, 2)
  10.  
  11. fib_level_0 = ta.highest(high, 2) - (fib_range * fib_0)
  12. fib_level_1 = ta.highest(high, 2) - (fib_range * fib_1)
  13.  
  14. // RSI
  15. rsi_length = input(14, "RSI Length")
  16. rsi_overbought = input(70, "RSI Overbought Level")
  17. rsi_oversold = input(30, "RSI Oversold Level")
  18.  
  19. rsi_value = ta.rsi(close, rsi_length)
  20.  
  21. // Determine buy and sell conditions
  22. buy_condition = ta.crossover(rsi_value, rsi_oversold) and close > fib_level_1
  23. sell_condition = ta.crossunder(rsi_value, rsi_overbought) and close < fib_level_0
  24.  
  25. // Plot Fibonacci levels
  26. plot(fib_level_0, color=color.red, linewidth=2)
  27. plot(fib_level_1, color=color.green, linewidth=2)
  28.  
  29. // Plot RSI
  30. plot(rsi_value, "RSI", color=color.blue, linewidth=2)
  31.  
  32. // Plot buy and sell signals
  33. plotshape(buy_condition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
  34. plotshape(sell_condition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
  35.  
Advertisement
Add Comment
Please, Sign In to add comment