如何将策略变成不重新粉刷的标签
我有一个策略,该策略一次只能在每个方向上进行一次交易,但是我想将其变成带有图形标签标签的指标。当我的购买或出售参数连续击中不止一次时,我尝试使用变量增加的每种方法都无法关闭标签,直到相反的信号出现。多次我希望它发出一个信号,然后关闭直到满足相对的交易参数。因此,一个购买信号,然后是一个卖出信号,中间没有无关的信号。我该如何实现?
//Strategy Trade Signal Bull
if bull
strategy.entry('Bull', strategy.long, comment='Bull')
strategy.close('Bull', when=bear, comment='Bear')
//Strategy Trade Signal Bear
if bear
strategy.entry('Bear', strategy.short, comment='Bear')
strategy.close('Bear', when=bull, comment='Bull')
I have a strategy built that only takes one trade in each direction at a time, but I'd like to turn it into just an indicator with labels using plotshape. Every method I have tried to use a variable increase when my buy or sell parameter hits more than once in a row, doesn't work to turn the labels off until the opposite signal comes in. So basically it is repainting a buy or sell signal multiple times when I want it to give one signal and then shut off until the opposite trade parameters are met. So one buy signal, then one sell signal, no irrelevant signals in the middle. How can I achieve this?
//Strategy Trade Signal Bull
if bull
strategy.entry('Bull', strategy.long, comment='Bull')
strategy.close('Bull', when=bear, comment='Bear')
//Strategy Trade Signal Bear
if bear
strategy.entry('Bear', strategy.short, comment='Bear')
strategy.close('Bear', when=bull, comment='Bull')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要一个变量才能查看是否已经很长。
这应该给你一个想法:
You need a variable to see if you are already long.
This should give you an idea: