简体   繁体   English

Pine Script Strategy 记录条形框架(一定数量的条形)上指标的条件

[英]Pine Script Strategy that records conditions from indicators on a frame of bars (a certain number of bars)

I have created a custom indicator that fuses 4 different indicators, each indictor has a buy and sell boolean signal.我创建了一个融合了 4 个不同指标的自定义指标,每个指标都有一个买卖信号 boolean。 My indicator requires 3 out of the 4 buy signals to be true in order to send a buy signal and vise versa for sell.我的指标要求 4 个买入信号中的 3 个为真,以便发送买入信号,反之亦然。 My problem is that pine script runs the script on every bar therefore checking the 4 indicators conditions on a single bar and returning a buy signal if 3 out of the 4 conditions are true on a single bar.我的问题是,pine 脚本在每个柱上运行脚本,因此检查单个柱上的 4 个指标条件,如果 4 个条件中的 3 个在单个柱上为真,则返回买入信号。 What I want to accomplish is to send a buy signal if 3 out of 4 are true on a frame of bars.我想要完成的是,如果 4 条柱线中有 3 条为真,则发送买入信号。 For example on a frame of 10 bars (ind1 true on bar1, ind2 true on bar 4, ind3 false on bar6, ind4 true on bar10)if 3 of the 4 are true in this frame a buy signal should be sent(or plotted).例如,在 10 条柱的框架上(第 1 条上的 ind1 为真,第 4 条上的 ind2 为真,第 6 条上的 ind3 为假,第 10 条上的 ind4 为真)如果此框架中 4 条中的 3 条为真,则应发送(或绘制)买入信号. Is this possible in any way?这有可能吗?

I have read the pine script documentation but couldnt find anything of use我已经阅读了松树脚本文档,但找不到任何有用的东西

Without providing the code, its hard to provide proper guidance that fits into your existing work.如果不提供代码,就很难提供适合您现有工作的适当指导。

I suggest looking into defining those four 'Indicators' (maybe "Case" or "Scenario" is a better phrase to use?") into UDT 's and add an eg "status" field as bool you update on every bar.我建议考虑将这四个“指标”(也许“Case”或“Scenario”是一个更好用的短语?)定义到UDT中,并添加一个例如“status”字段作为您在每个柱上更新的 bool。

Then count the status fields that are "true" and if the result is >= 3, execute your signal.然后计算为“真”的状态字段,如果结果 >= 3,则执行您的信号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM