Pine-Script:当价格在 y 时间间隔内变化 x 时提醒我

问题描述 投票:0回答:2

我正在尝试做的是一个脚本,它会提醒我有关快速和大幅价格变动的信息,例如:

当 BTC 价格在 5 分钟或更短时间内下跌(在蜡烛的最大值和最小值之间)超过 100 点时,通知我。

我检查了文档,但由于我不是很有经验的程序员,所以我被卡住了。你们有什么建议我应该如何处理这个?

我尝试了标准价格提醒,但它们只允许我设置特定价格的提醒。我对价格本身不感兴趣,但它是运动。

pine-script algorithmic-trading
2个回答
0
投票

您可以使用

ta.lowest()
ta.highest()
函数来获取您定义的回顾期内的最低价和最高价。然后计算点数之间的差异并触发您的警报。

如果你想为当前蜡烛做,只需使用

low
high

使用以下获取点数:

syminfo.mintick * (syminfo.type == "forex" ? 10 : 1)

0
投票

谢谢,这很有帮助。

我现在拥有的东西似乎有效:

study("Price Move Alert", overlay=false)


pipThreshold = input(50, title="Pip Threshold")
timeFrame = input("5", title="Time Frame", options=["1", "5", "15", "30", "60", "D"])

maxPrice = security(syminfo.tickerid, timeFrame, high)
minPrice = security(syminfo.tickerid, timeFrame, low)

priceChange = (maxPrice - minPrice) / syminfo.mintick

if priceChange > pipThreshold
    message = "BTC price changed by " + tostring(priceChange) + " pips in " + timeFrame + "-minute(s)."
    alert(message)

plot(priceChange, title="Price Change (Pips)", color=color.blue, linewidth=2) ```
© www.soinside.com 2019 - 2024. All rights reserved.