Pinescript 重复警报

编程入门 行业动态 更新时间:2024-10-10 09:22:23
本文介绍了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 重复警报

本文发布于:2023-11-27 11:39:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1637907.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   Pinescript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!