想請教一下
我想要寫多個條件去偵測進場點和出場點是怎麼寫呢?
比如 我要設定進場是
1. close 大於 MA100 就進場 空
2.macd>0 就進場 多
3.close到布林上通道就進場 多
4.close 小於 MA20 就做空
出場是
1. close >200MA 出場
2.close cross below bb 出場
3.close <200MA and close>150MA 停利出場
4.close <100MA and close >130mA 停利出場
想要讓程式 判斷 做多,由最上面賺最多的判斷下來,讓波段長一點,但怎麼都寫都不會出場,要不然就是出場會變成都是賺最少的呢?
if close cross over bbup then setposition(1,label:="多"); if MACDss>0 then setposition(1,label:="多"); if close > M100 then setposition(-1,label:="空"); if clsoe < m20 then setposition(-1,label:="空"); if position=1 and close>MA210 then setposition(0); if position=1 and close cross below bbmin then setposition(0); if position=1 and close<M200 and clsoe>150M then setposition(0); if position=1 and close<M100 and close>130M then setposition(0);
我用過 上面這樣的IF,也用過IF...else...end,
但好像沒辦法寫出我想要的,我有看過 IF / THEN / ELS 的說明
但好像還是無法,想請問 如果想要多用的判斷式來進場和出場怎寫呢?
比如說: 有6條均線,突破最上面的停利出場,一路判斷下來到停損。
3 評論