|
本帖最後由 zx0988158941 於 20-12-23 22:34 編輯
想了解,在程式碼中,marketposition 判斷的有無是如何影響到交易的判斷的舉例:
var:avg1(0),avg2(0);
value1 = average(c,10);
value2 = average(c,20);
avg1 = value1 > value2;
avg2 = value1 < value2;
if marketposition <> 1 and avg1 then buy next bar at highest(h,1) stop;
if marketposition <> -1 and avg2 then sellshort next bar at lowest(l,1) stop;
跟
if avg1 then buy next bar at highest(h,1) stop;
if avg2 then sellshort next bar at lowest(l,1) stop;
上圖是同一時間,下面策略多了marketposition的判斷而多空單進場,想知道為何交易點不同的原因。
|
|