XAUUSD M30 Impulse

signfx007 · study · 82 行 · 点赞 120 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

//@version=6
indicator("XAUUSD M30 Impulse 250+ Pips", overlay=true, max_lines_count=500)
 
// SETTINGS
minMove = input.float(25.0, "Minimum Movement ($)", step=0.1)
minBodyPercent = input.float(60, "Minimum Body %", minval=1, maxval=100)
lineLength = input.int(5, "Line Length", minval=1, maxval=50)
lineWidth = input.int(1, "Line Width", minval=1, maxval=3)
 
// TIMEFRAME
isM30 = timeframe.isminutes and timeframe.multiplier == 30
 
// CANDLE CALCULATIONS
bodySize = math.abs(close - open)
candleRange = high - low
bodyPercent = candleRange > 0 ? bodySize / candleRange * 100 : 0
 
// MINIMUM 250 PIPS = $25
bigCandle = bodySize >= minMove
 
// IMPULSE CONDITIONS
bearishImpulse = isM30 and close < open and bigCandle and bodyPercent >= minBodyPercent
bullishImpulse = isM30 and close > open and bigCandle and bodyPercent >= minBodyPercent
 
// SELL LINE
if bearishImpulse and barstate.isconfirmed
    line.new(
         x1=bar_index - 1,
         y1=low[1],
         x2=bar_index + lineLength,
         y2=low[1],
         color=color.blue,
         width=lineWidth
         )
 
// BUY LINE
if bullishImpulse and barstate.isconfirmed
    line.new(
         x1=bar_index - 1,
         y1=high[1],
         x2=bar_index + lineLength,
         y2=high[1],
         color=color.blue,
         width=lineWidth
         )
 
// SELL LABEL
plotshape(
     bearishImpulse and barstate.isconfirmed,
     title="SELL",
     style=shape.labeldown,
     location=location.abovebar,
     color=color.red,
     text="SELL",
     textcolor=color.white,
     size=size.tiny
     )
 
// BUY LABEL
plotshape(
     bullishImpulse and barstate.isconfirmed,
     title="BUY",
     style=shape.labelup,
     location=location.belowbar,
     color=color.green,
     text="BUY",
     textcolor=color.white,
     size=size.tiny
     )
 
// ALERTS
alertcondition(
     bearishImpulse and barstate.isconfirmed,
     title="SELL 250+ Pips",
     message="SELL: XAUUSD M30 impulse 250+ pips"
     )
 
alertcondition(
     bullishImpulse and barstate.isconfirmed,
     title="BUY 250+ Pips",
     message="BUY: XAUUSD M30 impulse 250+ pips"
     )

← 返回列表