赶高赶低的策略
strategy to catching high and low
我正在尝试一种具有上升和下降功能的策略,其中:
如果有 3 个连续较低的低点(下降)并且当前的低点更高(上升)则买入。
如果连续出现 3 个更高的低点(上升)并且当前的低点更低(下降),则卖出。
但是 AND 条件永远不会触发。你能指出我的原因吗?
//@version=4
study(title="RiseFall", overlay=true)
TrendPrd = input (defval=3, title="Trend Period", type=input.integer, minval=3, step=1)
ChangePrd = input (defval=1, title="Change Period", type=input.integer, minval=1, step=1)
Fall2Rise = falling(low, TrendPrd) and rising (low,ChangePrd)
Rise2Fall = rising (low, TrendPrd) and falling(low,ChangePrd)
plotshape(Fall2Rise, title="BUY", style=shape.labelup, location=location.belowbar, color=color.black, transp=0, text="BUY", textcolor=color.white, size=size.tiny)
plotshape(Rise2Fall, title="SELL", style=shape.labeldown, location=location.abovebar, color=color.black, transp=0, text="SELL", textcolor=color.white, size=size.tiny)
它应该像捕获的那样在这里工作。
enter image description here
使用绘图来调试您的条件。绿线是你的上升和下降相互交叉的时候。这是永远不会发生的:
//@version=4
study(title="RiseFall", overlay=false)
TrendPrd = input (defval=3, title="Trend Period", type=input.integer, minval=3, step=1)
ChangePrd = input (defval=1, title="Change Period", type=input.integer, minval=1, step=1)
Fall2Rise = ( falling(low, TrendPrd) and rising (low,ChangePrd) )
// simplifying Fall2Rise:
plot ( falling(low, TrendPrd) ? 1 : 0 )
plot ( rising (low,ChangePrd) ? 1 : 0, color = color.red)
plot ( Fall2Rise ? 1 : 0 , color = color.green )
我正在尝试一种具有上升和下降功能的策略,其中: 如果有 3 个连续较低的低点(下降)并且当前的低点更高(上升)则买入。 如果连续出现 3 个更高的低点(上升)并且当前的低点更低(下降),则卖出。 但是 AND 条件永远不会触发。你能指出我的原因吗?
//@version=4
study(title="RiseFall", overlay=true)
TrendPrd = input (defval=3, title="Trend Period", type=input.integer, minval=3, step=1)
ChangePrd = input (defval=1, title="Change Period", type=input.integer, minval=1, step=1)
Fall2Rise = falling(low, TrendPrd) and rising (low,ChangePrd)
Rise2Fall = rising (low, TrendPrd) and falling(low,ChangePrd)
plotshape(Fall2Rise, title="BUY", style=shape.labelup, location=location.belowbar, color=color.black, transp=0, text="BUY", textcolor=color.white, size=size.tiny)
plotshape(Rise2Fall, title="SELL", style=shape.labeldown, location=location.abovebar, color=color.black, transp=0, text="SELL", textcolor=color.white, size=size.tiny)
它应该像捕获的那样在这里工作。 enter image description here
使用绘图来调试您的条件。绿线是你的上升和下降相互交叉的时候。这是永远不会发生的:
//@version=4
study(title="RiseFall", overlay=false)
TrendPrd = input (defval=3, title="Trend Period", type=input.integer, minval=3, step=1)
ChangePrd = input (defval=1, title="Change Period", type=input.integer, minval=1, step=1)
Fall2Rise = ( falling(low, TrendPrd) and rising (low,ChangePrd) )
// simplifying Fall2Rise:
plot ( falling(low, TrendPrd) ? 1 : 0 )
plot ( rising (low,ChangePrd) ? 1 : 0, color = color.red)
plot ( Fall2Rise ? 1 : 0 , color = color.green )