Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This Pine Scriptô code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © forexninja69
- //@version=5
- indicator(title='Ninja Trend v2', overlay=true)
- timeFrameRange = input.timeframe("", title="Time Frame")
- src = input(title='Source', defval=close)
- fastMA = input.int(title='Fast moving average', defval=12, minval=7)
- slowMA = input.int(title='Slow moving average', defval=26, minval=7)
- signalLength = input.int(9, 'Signal Length', minval=1)
- BuyColor = input(title='Buy Color ', defval=color.green)
- SellColor = input(title='Sell Color ', defval=color.red)
- NeutralColor = input(title='Neutral Color ', defval=#787c86)
- var GRPd = "Dashboard Settings"
- showdashboard = input(title='Show Panel ', defval=true, group=GRPd)
- string tableYposInput = input.string("top", "Panel position", inline = "11", options = ["top", "middle", "bottom"], group = GRPd)
- string tableXposInput = input.string("right", "", inline = "11", options = ["left", "center", "right"], group = GRPd)
- PanelColor = input(color.new(color.black, 30), 'Panel BackGround Color', group=GRPd)
- textpanelcolor = input(color.new(color.white, 0), 'Text Color', group=GRPd)
- dashwidth = input.int(7, 'Dashboard Width', minval=1, maxval=25, group=GRPd)
- sizeOptiondash = input.string(title="Text Size Dashboard",
- options=["Auto", "Huge", "Large", "Normal", "Small", "Tiny"],
- defval="Small", group=GRPd)
- labelSizedash = (sizeOptiondash == "Huge") ? size.huge :
- (sizeOptiondash == "Large") ? size.large :
- (sizeOptiondash == "Small") ? size.small :
- (sizeOptiondash == "Tiny") ? size.tiny :
- (sizeOptiondash == "Auto") ? size.auto :
- size.normal
- [currMacd, _, _] = ta.macd(close[0], fastMA, slowMA, 9)
- [prevMacd, _, _] = ta.macd(close[1], fastMA, slowMA, 9)
- signal = ta.sma(currMacd, signalLength)
- is_bull_bar = currMacd > 0 and signal > 0
- is_bear_bar = currMacd < 0 and signal < 0
- bbar=request.security(syminfo.tickerid,timeFrameRange,is_bull_bar,lookahead = barmerge.lookahead_on)
- sbar=request.security(syminfo.tickerid,timeFrameRange,is_bear_bar,lookahead = barmerge.lookahead_on)
- barcolor = bbar ? BuyColor : sbar ? SellColor : barstate.isconfirmed ? NeutralColor : na
- barcolor(barcolor, 0, false)
- if(showdashboard and barstate.islast)
- 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)
- // Main headings
- trend_text=bbar[1] ? "Buy" : sbar[1] ? "Sell" : "Neutral"
- 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)
- table.set_bgcolor(mytable,barcolor[1])
- alertset = bbar ? 1 : sbar ? -1 : 0
- alertcondition(alertset==1 and alertset[1]==0,"Buy Alert", message = ' Buy Alert ')
- alertcondition(alertset==1 and alertset[1]==0,"Sell Alert", message = ' Sell Alert ')
Advertisement
Comments
-
- 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