松木脚本策略当ta.cross和barcolor时进入位置



我想在条形图颜色不是橙色并且数据叉(高,upper3(((upper3是布林带((时进入空头头寸。当条形图的颜色为橙色时,不应有任何输入。

//Kerzenfarben wenn High & Low auf äußeren BB
colourForBar = if (close > upper2_oben[1])
color.orange
else
na
barcolor(color=colourForBar)
colourForBar2 = if (close < lower2_unten[1])
color.orange
else
na
barcolor(color=colourForBar2)
//short Einstieg
if barcolor(colourForBar ? color.orange : na) and ta.cross(high, upper3)
strategy.entry("Short", strategy.short)

有办法做到这一点吗?

您将条形图颜色设置为橙色,条件为:(close > upper2_oben[1])。您可以使用not运算符来判断条形图的颜色是还是橙色。

潜在的问题是,您有两个bacolor函数调用来设置条形图。所以,你需要弄清楚你想在条件检查中使用哪一个。

is_not_orange = not (close > upper2_oben[1])
entry_cond = is_not_orange and ta.cross(high, upper3)
if (entry_cond)
strategy.entry("Short", strategy.short)

注意:这可能是一些格式问题,但您的代码不遵守缩进规则。如果你还没有遵守规则,一定要遵守。

最新更新