本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tradedots
//@version=5
strategy("Price and Volume Breakout Buy Strategy [TradeDots]", overlay=true, initial_capital = 10000, default_qty_type = strategy.percent_of_equity, default_qty_value = 70, commission_type = strategy.commission.percent, commission_value = 0.01)
input_price_breakout_period = input.int(60, "Price Breakout Period")
input_volume_breakout_period = input.int(60, "Volume Breakout Period")
input_trendline_legnth = input.int(200, "Trendline Length")
price_highest = ta.highest(input_price_breakout_period)
volume_highest = ta.highest(volume, input_volume_breakout_period)
if close > price_highest[1] and volume > volume_highest[1] and close > ta.sma(close ,input_trendline_legnth) and strategy.opentrades == 0
strategy.entry("Long", strategy.long)
line.new(bar_index[input_price_breakout_period], price_highest[1], bar_index, price_highest[1], color = #9cff87, width = 2)
label.new(bar_index,low, "🟢 Breakout Buy", style = label.style_label_up, color = #9cff87)
if close < ta.sma(close, input_trendline_legnth) and close[1] < ta.sma(close, input_trendline_legnth) and close[2] < ta.sma(close, input_trendline_legnth) and close[3] < ta.sma(close, input_trendline_legnth) and close[4] < ta.sma(close, input_trendline_legnth) and strategy.opentrades > 0
strategy.close("Long")
label.new(bar_index, high, "🔴 Close Position", style = label.style_label_down, color = #f9396a, textcolor = color.white)
plot(ta.sma(close, input_trendline_legnth), color = color.white, linewidth = 2)
plotcandle(open, high, low, close, title='Candles', color = (close > ta.sma(close, input_trendline_legnth) ? #9cff87 : #f9396a), wickcolor=(close > ta.sma(close, input_trendline_legnth) ? #9cff87 : #f9396a), force_overlay = true)