本页源码来自 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/
// © samscripter
//@version=5
indicator(title="Engulfing pullback", shorttitle="EMA", overlay=true, timeframe="", timeframe_gaps=true)
var group_ma ="Ma Settings"
type_ma = input.string(title = "Choose Ma", defval = "SMA", options=["SMA", "EMA", "RMA", "WMA", "VWMA","SWMA","ALMA","VWAP"], group=group_ma)
ma_len = input.int(title = "Length", defval = 100, minval = 1, maxval = 1000, group=group_ma)
ma_src = input.source(close, title="Source",group = group_ma)
ma(source, length, type) =>
switch type
"SMA" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"RMA" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
"SWMA" => ta.swma(source)
"ALMA" => ta.alma(source, length, 0.85, 6)
"VWAP" => ta.vwap(source)
ma_p = ma(ma_src, ma_len, type_ma)
plot(ma_p, title="Smoothing Line", color=#f37f20)
// pullbacl condition
pull_buy = close>ma_p and ta.crossunder(low,ma_p)
pull_sell= close<ma_p and ta.crossover(high,ma_p)
// finding bullish engulf || Bearish engulf
final_buy =pull_buy[1] and close>close[1] and high>high[1] and open>low[1]
final_sell=pull_sell[1] and close<close[1] and low<low[1] and open<high[1]
plotshape(final_buy ,title = "Buy",style = shape.labelup,location = location.belowbar,color = color.green,text = "Buy",textcolor =color.white)
plotshape(final_sell,title = "Sell",style = shape.labeldown,location = location.abovebar,color = color.red,text = "Sell",textcolor =color.white)