Advertisement
xmd79

Ninja Trend v2

Feb 27th, 2024
655
1
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.01 KB | None | 1 0
  1. // This Pine Scriptô code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
  2. // © forexninja69
  3.  
  4. //@version=5
  5. indicator(title='Ninja Trend v2', overlay=true)
  6.  
  7.  
  8. timeFrameRange = input.timeframe("", title="Time Frame")
  9. src = input(title='Source', defval=close)
  10. fastMA = input.int(title='Fast moving average', defval=12, minval=7)
  11. slowMA = input.int(title='Slow moving average', defval=26, minval=7)
  12. signalLength = input.int(9, 'Signal Length', minval=1)
  13. BuyColor = input(title='Buy Color ', defval=color.green)
  14. SellColor = input(title='Sell Color ', defval=color.red)
  15. NeutralColor = input(title='Neutral Color ', defval=#787c86)
  16. var GRPd = "Dashboard Settings"
  17. showdashboard = input(title='Show Panel ', defval=true, group=GRPd)
  18. string tableYposInput = input.string("top", "Panel position", inline = "11", options = ["top", "middle", "bottom"], group = GRPd)
  19. string tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"], group = GRPd)
  20. PanelColor = input(color.new(color.black, 30), 'Panel BackGround Color', group=GRPd)
  21.  
  22. textpanelcolor = input(color.new(color.white, 0), 'Text Color', group=GRPd)
  23. dashwidth = input.int(7, 'Dashboard Width', minval=1, maxval=25, group=GRPd)
  24. sizeOptiondash = input.string(title="Text Size Dashboard",
  25. options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"],
  26. defval="Small", group=GRPd)
  27.  
  28.  
  29.  
  30. labelSizedash = (sizeOptiondash == "Huge") ? size.huge :
  31. (sizeOptiondash == "Large") ? size.large :
  32. (sizeOptiondash == "Small") ? size.small :
  33. (sizeOptiondash == "Tiny") ? size.tiny :
  34. (sizeOptiondash == "Auto") ? size.auto :
  35. size.normal
  36.  
  37. [currMacd, _, _] = ta.macd(close[0], fastMA, slowMA, 9)
  38. [prevMacd, _, _] = ta.macd(close[1], fastMA, slowMA, 9)
  39.  
  40. signal = ta.sma(currMacd, signalLength)
  41.  
  42.  
  43.  
  44. is_bull_bar = currMacd > 0 and signal > 0
  45. is_bear_bar = currMacd < 0 and signal < 0
  46.  
  47.  
  48. bbar=request.security(syminfo.tickerid,timeFrameRange,is_bull_bar,lookahead = barmerge.lookahead_on)
  49. sbar=request.security(syminfo.tickerid,timeFrameRange,is_bear_bar,lookahead = barmerge.lookahead_on)
  50.  
  51. barcolor = bbar ? BuyColor : sbar ? SellColor : barstate.isconfirmed ? NeutralColor : na
  52.  
  53. barcolor(barcolor, 0, false)
  54.  
  55.  
  56. if(showdashboard and barstate.islast)
  57. var table mytable = table.new(tableYposInput + "_" + tableXposInput,9, 10,border_width = 2,frame_color = color.black,frame_width = 3,border_color =color.new(color.black,50),bgcolor=PanelColor)
  58.  
  59.  
  60. // Main headings
  61. trend_text=bbar[1] ? "Buy" : sbar[1] ? "Sell" : "Neutral"
  62. table.cell(mytable, 0 ,0, trend_text, text_color = textpanelcolor,width = int(dashwidth+1),text_size = labelSizedash,text_halign = text.align_center,text_font_family=font.family_monospace)
  63. table.set_bgcolor(mytable,barcolor[1])
  64.  
  65. alertset = bbar ? 1 : sbar ? -1 : 0
  66.  
  67. alertcondition(alertset==1 and alertset[1]==0,"Buy Alert", message = ' Buy Alert ')
  68. alertcondition(alertset==1 and alertset[1]==0,"Sell Alert", message = ' Sell Alert ')
  69.  
Advertisement
Comments
  • # text 0.12 KB | 0 0
    1. download all types of premium tradingview indicators codes available on telegram - https://t.me/tradingview_premium_indicator
Add Comment
Please, Sign In to add comment
Advertisement