繁体   English   中英

TradingView Pine Plot 箭头基于多个条件

[英]TradingView Pine Plot Arrow Based on Multiple Conditions

我是 Pine Editor 的新手,在制定策略时遇到了一些问题。 我有一些条件/确认必须满足,以便 plot 在蜡烛下方的绿色向上箭头长 position。

以下是我当前的代码,但我一直收到相同的错误“第 75 行:无法在本地 scope 中使用 'plotshape'。

任何帮助表示赞赏!

//@version=4
strategy(title="Directional Movement Index", shorttitle="DMI", format=format.price, precision=4, overlay=true)

// Setup DMI Indicator
len = input(5, minval=1, title="DI Length")
lensig = input(1, title="ADX Smoothing", minval=1, maxval=50)

up = change(high)
down = -change(low)
plusDM = na(up) ? na : (up > down and up > 0 ? up : 0)
minusDM = na(down) ? na : (down > up and down > 0 ? down : 0)
trur = rma(tr, len)
plus = fixnan(100 * rma(plusDM, len) / trur)
minus = fixnan(100 * rma(minusDM, len) / trur)
sum = plus + minus
adx = 100 * rma(abs(plus - minus) / (sum == 0 ? 1 : sum), lensig)

// Setup MACD 1
[macdLine_1, signalLine_1, histLine_1] = macd(close, 5, 10, 1)
plot(signalLine_1, color=color.gray)
plot(histLine_1, color=color.black, style=plot.style_columns)

// Setup MACD 2
[macdLine_2, signalLine_2, histLine_2] = macd(close, 12, 18, 1)
plot(signalLine_2, color=color.red)
plot(histLine_2, color=color.red, style=plot.style_histogram)

// Setup EMA/MA
ema50 = ema(close, 50)
ma4 = sma(close, 4)

// Setup Heikin Ashi Candles
ha_open = security(heikinashi(syminfo.tickerid), timeframe.period, open)
ha_high = security(heikinashi(syminfo.tickerid), timeframe.period, high)
ha_low = security(heikinashi(syminfo.tickerid), timeframe.period, low)
ha_close = security(heikinashi(syminfo.tickerid), timeframe.period, close)

// MA Confirmations
long_ma_ema_crossover = crossover(ma4, ema50)
short_ma_ema_crossover = crossunder(ma4, ema50)

// Heikin Ashi Confirmations
flat_bottom = low == open // BUY
flat_top = high == open // SELL
long_entry_candle = false

// MACD Confirmations
long_macd = crossover(signalLine_1, 0)
short_macd = crossunder(signalLine_1, 0)

// DMI Confirmations
high_momentum = crossover(adx, 50)
sellers_market = minus > plus
buyers_market = plus > minus

// Entry for long position if all confirmations below are true
if (long_ma_ema_crossover and flat_bottom and long_macd and high_momentum and buyers_market)
    strategy.entry("Long", true)
    plotshape(flat_bottom, style=shape.arrowdown, location=location.belowbar, color=color.red, transp=50) // Flat Bottom Candle


是的,因为它是本地 scope。 你应该使用类似的东西:

plotshape((long_ma_ema_crossover and flat_bottom and long_macd and high_momentum and buyers_market) ? flat_bottom : na, style=shape.arrowdown, location=location.belowbar, color=color.red, transp=50)

(你不能在 if 语句中使用 plot,所以排除它)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM