本帖最後由 lantis 於 13-8-14 10:52 編輯
inputs:
ProfitTarget(240),
StopLoss(80),
ProfitProtectTrigger(120),
ProfitProtectLimit(60)
;
setprofittarget(ProfitTarget);
setstoploss(StopLoss);
if marketposition = 0 then begin
if buycond then buy next bar at price limit;
if sellcond then sell short next bar at price limit;
end;
if maxpositionprofit >= ProfitProtectTrigger then begin
if positionprofit < ProfitProtectLimit then begin
if marketposition = 1 then sell next bar at market;
if marketposition = -1 then buy next bar at market;
end;
end;
以上是部分的 code
為何跑出來結果永遠都在 maxpositionprofit >= ProfitProtectTrigger 後下一個bar 就結束position?
Profit 永遠達不到 240
似乎 if positionprofit < ProfitProtectLimit 這條件永遠未被檢驗?
positionprofit 改成 positionprofit (0) 也一樣
|