COCO研究院

 找回密碼
 註冊
搜索
查看: 2559|回復: 2

MC Strategy 裡 maxpositionprofit 及 positionprofit 運用問題

[複製鏈接]
發表於 13-8-14 09:03 | 顯示全部樓層 |閱讀模式
本帖最後由 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) 也一樣



 樓主| 發表於 13-8-14 11:02 | 顯示全部樓層
本帖最後由 lantis 於 13-8-14 11:48 編輯

結果發現 positionprofit 的 value 都是 0,
所以 positionprofit < ProfitProtectLimit  永遠成立

if maxpositionprofit >= ProfitProtectTrigger then begin
        print(_PrintDateTime,  maxpositionprofit , positionprofit  );

怎會如此?
 樓主| 發表於 13-8-14 12:47 | 顯示全部樓層
自力救濟用

profit = (C - EntryPrice) * BigPointValue  取代positionprofit 解決了;

還是不懂為何 positionprofit 永遠是 0
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

手機版|Archiver|站長信箱|廣告洽詢|COCO研究院

GMT+8, 24-5-13 05:49

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回復 返回頂部 返回列表
理財討論網站 | AI繪圖AI超擬真美女AI beauty AI Stable DiffusionAI正妹AI Lookbook