Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
- // © sonnyparlin
- //@version=5
- indicator(shorttitle='MACD+Indicator', title='MACD Indicator', overlay=true)
- [macdLine, signalLine, histLine] = ta.macd(close, 12, 26, 9)
- macdLineBottom = input.float(-180, title="Enter when MACD line is > than (x)")
- enterLong = ta.crossover(macdLine,signalLine) and macdLine < macdLineBottom
- // Enter long
- var float entryPrice = na
- if enterLong
- entryPrice := close
- label.new(bar_index,
- low,
- "Go Long ▲",
- color=color.lime,
- size = size.normal,
- style=label.style_label_up)
- exitWithProfit = input.float(2, title='Signal with at least (x%) profit')/100
- macdLineTop = input.float(180, title="Exit when MACD line is > than (x)")
- exitCond1 = ta.crossunder(macdLine,signalLine) and macdLine > macdLineTop
- exitCond2 = (close - entryPrice) / close > exitWithProfit
- exitLong = exitCond1 and exitCond2
- if exitLong
- label.new(bar_index,
- high,
- "Exit Long ▼",
- color=color.red,
- size = size.normal,
- style=label.style_label_down)
Advertisement
Add Comment
Please, Sign In to add comment