COCO研究院

 找回密碼
 註冊
搜索
查看: 1737|回復: 0

[範例程式碼] 求教股市追蹤止利程式碼

[複製鏈接]
發表於 21-2-8 09:41 | 顯示全部樓層 |閱讀模式
各位大大, 我想寫一段追蹤止利的程式碼
條件是買入後最高收市價回落 5% 賣出,
但寫成了運作不成功, 煩請斧正~~ 拍謝~

inputs: StopLossPct( .08 ), PosClosePrecent(.95);

variables : MA50(0), PosClose(0);

MA50 = XAverage(close,50);

condition1 = low cross below MA50 and close < MA50;

if condition1 then buy next bar at market;

PosClose = Close[1];

if Close>PosClose then
             PosClose = Close
             else
             PosClose = PosClose[1];

condition2 = close <= (PosClose * PosClosePrecent);

if condition2 then sell next bar at market;


SetStopShare ;
if MarketPosition = 1 then
        SetStopLoss( EntryPrice * StopLossPct )


您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

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

GMT+8, 24-4-24 20:27

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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