首页 > 解决方案 > 将具有不同时间范围的新条件添加到当前脚本

问题描述

我在 tradingview 中为脚本编写了代码。它工作得很好,但现在我想添加另一个条件。仅当当前拨号蜡烛的值大于前一个(昨天)时才会触发买入信号。

我在 1 分钟图表和 15 分钟图表中使用此脚本,所以,我不知道如何调用每日图表的值并添加到我的警报中。

任何人都可以帮助我吗?

谢谢

// Parameters

RSILowerLevel1 = 42
RSIUpperLevel1 = 74
BuyTrigger1 = src1 < lower1
BSellTrigger1 = src1 > upper1
rsiBuyGuard1 = rsi > RSILowerLevel1
rsiSellGuard1 = rsi > RSIUpperLevel1



//////////Signals 

isLong = false              // A flag for going LONG
isLong := nz(isLong[1])     // Get the previous value of it

isShort = false             // A flag for going SHORT
isShort := nz(isShort[1])   // Get the previous value of it

//RSIMain = rsi(close, 14)

buySignal = (BuyTrigger1 and rsiBuyGuard1) and not isLong    // Buy only if we are not already long
sellSignal = (BSellTrigger1 and rsiSellGuard1) and not isShort  // Sell only if we are not already short

if (buySignal)
    isLong := true
    isShort := false

if (sellSignal)
    isLong := false
    isShort := true
    
alertcondition(buySignal, title='BUY', message='BUY')
alertcondition(sellSignal, title='SELL', message='SELL')

plotshape(series=buySignal, title="BUY", text="BUY", style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(series=sellSignal, title="SELL", text="SELL", style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)

标签: pine-script

解决方案


推荐阅读