本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © c4ss10p314
//@version=4
study(title = "3emaFXind", shorttitle = "3emaInd", overlay=true)
//input variables
inpHigherTimeframe = input("240", title = "HigherTimeframe")
inpSecLength = input(3, title = "Security Length")
switchVisSecEma8 = input(title = "Show Security-EMA8", type = input.bool, defval=false)
switchVisSecEma21 = input(title = "Show Security-EMA21", type=input.bool, defval=false)
bullEnHeight = input(title="BullEn, Height (Pips)",minval=1,maxval=100,step=1,defval=3,confirm=false)
bullEnAbove = input(title="BullEn Above (Pips)",minval=1,maxval=100,step=1,defval=1,confirm=false)
bullEnBelow = input(title="BullEn, Below (Pips)",minval=1,maxval=100,step=1,defval=0,confirm=false)
bearEnHeight = input(title="BearEn, Height (Pips)",minval=1,maxval=100,step=1,defval=3,confirm=false)
bearEnAbove = input(title="BearEn Above (Pips)",minval=1,maxval=100,step=1,defval=0,confirm=false)
bearEnBelow = input(title="BearEn, Below (Pips)",minval=1,maxval=100,step=1,defval=1,confirm=false)
//Security
secEma8() => ema(close[inpSecLength], 8)
secEma21() => ema(close[inpSecLength], 21)
dailyEma8 = security(syminfo.tickerid, inpHigherTimeframe, secEma8())
dailyEma21 = security(syminfo.tickerid, inpHigherTimeframe, secEma21())
secTrend = dailyEma8 > dailyEma21 ? 1 : 0
TranspSecEma8 = switchVisSecEma8 == true ? 0 : 100
TranspSecEma21 = switchVisSecEma21 == true ? 0 : 100
//Candlestick patterns
bullEngulfing = ((open[1] - close[1]) / syminfo.mintick >= bullEnHeight) and (close > open) and ((close - open[1]) / syminfo.mintick >= bullEnAbove) and ((close[1] - open) / syminfo.mintick >= bullEnBelow)
bearEngulfing = ((close[1] - open[1]) / syminfo.mintick >= bearEnHeight) and (close < open) and ((open - close[1]) / syminfo.mintick >= bearEnAbove) and ((open[1] - close) / syminfo.mintick >= bearEnBelow)
ema8 = ema(close, 8)
ema13 = ema(close, 13)
ema21 = ema(close, 21)
//plot conditions
//Engulfers
plotEngBullSeries = ema8 > ema21 and open > ema13 and bullEngulfing ? 1 : 0
plotEngBearSeries = ema8 < ema21 and open < ema13 and bearEngulfing ? 1 : 0
LongDirection = plotEngBullSeries == 1 and secTrend == 1 ? 1 : 0
ShortDirection = plotEngBearSeries == 1 and secTrend == 0 ? 1 : 0
//chart plotters
plotshape(series = LongDirection, style = shape.triangleup, location = location.abovebar, color = color.green, text = 'Eng', textcolor = color.green)
plotshape(series = ShortDirection, style = shape.triangledown, location = location.abovebar, color = color.red, text = 'Eng', textcolor = color.red)
plot(ema8, color = color.blue, linewidth=2) //plot_0
plot(ema13, color = color.green, linewidth=2) //plot_1
plot(ema21, color = color.orange, linewidth=2) //plot_2
plot(dailyEma8, color = color.yellow, transp = TranspSecEma8) //plot_3
plot(dailyEma21, color = color.blue, transp = TranspSecEma21) //plot_4
alertcondition(LongDirection or ShortDirection, title = "01-Engulfing Candle", message = "Asset: {{ticker}} Candle: {{close}} {{open}}")
// Check ob trend die letzten x Kerzen schon trend war
// Alerts - in message: DeltaStop = (abs(close - low[1]) / syminfo.mintick) + 3