求教股市追蹤止利程式碼
各位大大, 我想寫一段追蹤止利的程式碼條件是買入後最高收市價回落 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;
if Close>PosClose then
PosClose = Close
else
PosClose = PosClose;
condition2 = close <= (PosClose * PosClosePrecent);
if condition2 then sell next bar at market;
SetStopShare ;
if MarketPosition = 1 then
SetStopLoss( EntryPrice * StopLossPct )
頁:
[1]