我有一个孔雀鱼的策略,它应该进入长(当孔雀鱼在特定条件下变成绿色)或短(当孔雀鱼在特定条件下变成红色时)。为了确定pine脚本中的颜色,我使用了if/else。问题出在哪里?当两个条件都不满足时,我得到第三种颜色(比方说灰色),例如,在我得到red1=>grey=>red2的情况下,当red2发生时,我的策略发送信号关闭先前的交易,并以相同的方向打开新的交易。在我的策略中,灰色不是进入/退出位置的信号,所以我想让当前的“灰色”以与前一段着色相同的方式着色,直到满足完全相反的条件。我尝试了其他na,但这些中间条件仍然给我错误的信号,我也尝试将plotcolor=plotcolor 1 在'else‘中,但此类型的命令不能放在pine脚本中。有谁能帮我解决这个问题吗?
plot_color0 = if hma8>hma0[2] and hma7>hma0[2] and hma6>hma0[2] and hma5>hma0[2] and hma4>hma0[2] and hma3>hma0[2] and hma2>hma0[2] and hma1>hma0[2]
aqua
else
if hma8basically the problem happens when tradingview.com/x/AnFOTdEa colour turns blue (long signal which gives me command to close previous positions and to open new) after that turns grey and again blue and once again i get long signal (which closes my previous long position and opens it once again). What i want to figure out is how to set alert which either would not trigger after grey colour if previous trade signal direction was the same direction to previous signal or to remove this 'else gray' in the way, where the colour will change only if opposite direction conditions was met
if i put plot0 != gray in conditions alert simply doesn't trigger at all obviously, and i can't exclude 'else gray'
in the end i want alert to trigger only if previous trigger was in opposite direction besides longCondition and shortCondition mentioned above
发布于 2021-02-27 09:43:42
尝试此表单中的条件,灰色将仅保留在前几个条形上。
plot_color0 = gray
plot_color0 := if hma8>hma0[2] and hma7>hma0[2] and hma6>hma0[2] and hma5>hma0[2] and hma4>hma0[2] and hma3>hma0[2] and hma2>hma0[2] and hma1>hma0[2]
aqua
else
if hma8https://stackoverflow.com/questions/66378206
复制相似问题