Pinescript 重复警报 [英] Pinescript duplicate alerts

查看:111
本文介绍了Pinescript 重复警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用 pinescript 创建了一个非常基本的脚本.

I have created a very basic script in pinescript.

study(title='Renko Strat w/ Alerts', shorttitle='S_EURUSD_5_[MakisMooz]', overlay=true)

rc = close

buy_entry = rc[0] > rc[2]
sell_entry = rc[0] < rc[2]

alertcondition(buy_entry, title='BUY')
alertcondition(sell_entry, title='SELL')
plot(buy_entry/10)

问题是我收到了很多重复的警报.我想编辑此脚本,以便仅在上一个警报是卖出"警报时才收到买入"警报,反之亦然.这似乎是一个简单的问题,但我很难找到学习 pinescript 的好资源.因此,任何帮助将不胜感激.:)

The problem is that I get a lot of duplicate alerts. I want to edit this script so that I only get a 'Buy' alert when the previous alert was a 'Sell' alert and visa versa. It seems like such a simple problem, but I have a hard time finding good sources to learn pinescript. So, any help would be appreciated. :)

推荐答案

解决蜡烛图中重复更改的一种方法是使用每条柱线关闭一次"警报.但是对于替代警报(买入 - 卖出),您必须使用不同的逻辑对其进行编码.

One way to solve duplicate alters within the candle is by using "Once Per Bar Close" alert. But for alternative alerts (Buy - Sell) you have to code it with different logic.

我建议使用版本 3(在学习线上方显示的版本)而不是版本 1 和 2,您可以使用以下逻辑完成结果:

I Suggest to use Version 3 (version shown above the study line) than version 1 and 2 and you can accomplish the result by using this logic:

buy_entry  = 0.0
sell_entry = 0.0

buy_entry  := rc[0] > rc[2] and sell_entry[1] == 0? 2.0 : sell_entry[1] > 0 ? 0.0 : buy_entry[1]
sell_entry := rc[0] < rc[2] and buy_entry[1] == 0 ? 2.0 : buy_entry[1] > 0  ? 0.0 : sell_entry[1]

alertcondition(crossover(buy_entry ,1) , title='BUY' )
alertcondition(crossover(sell_entry ,1), title='SELL')

这篇关于Pinescript 重复警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆