請選擇 進入手機版 | 繼續訪問電腦版

COCO研究院

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

[範例程式碼] 台指當沖CDP程式碼分享+團購策略

[複製鏈接]
發表於 22-9-17 19:49 | 顯示全部樓層 |閱讀模式

以下是程式碼分享 如果有人可以改進績效 可以回復在留言區
input:in(6),notin(12),pa(59);
vars:cdp(0),AH(0),NH(0),NL(0),AL(0),DS(0),DB(0),mp(0),pv(0);
vars:value1(0),value2(0),value3(0),ac(0),AS(0),AB(0),dh(0),dl(0);

mp = marketposition;
pv = currentcontracts;

if date<>date[1] then begin
DS = 0;
DB = 0;
value1 = Highest(c,pa);
value2= lowest(c,pa);
value3 = c[1];
cdp = (value1+value2+2*value3)*0.25;
AH = cdp+(value1-value2);
NH = 2*cdp-value2;
AL = cdp-(value1-value2);
NL = 2*cdp-value1;
ac = currentbar;
AS=0;
AB=0;
dh=H;
dl=l;
end;

if h > dh then
dh = h;
if L< dl then
dl = l;

condition1 = time>=calctime(sess1starttime,in*barinterval) and time< calctime(1000,notin*barinterval) ;
condition2 = time>=calctime(sess1starttime,in*barinterval) and time< calctime(1000,(notin+3)*barinterval) {and countif(O<C,currentbar-ac)<=(currentbar-ac)*ratio };

if condition1  then begin

if DS = 0 and C >=NH and C<AH and countif(O>C,currentbar-ac) >= (currentbar-ac)/2  then begin
  sellshort("NH-S") next bar at market;
    DS = DS+1;
end;

if DB = 0 and c <=NL and C> AL and  countif(O<C,currentbar-ac) >= (currentbar-ac)/2   then begin
   buy("NL-L") next bar at market;
    DB = DB+1;
end;

end;

if condition2 then begin

if DB<=2 and C > AH and countif(O<C,currentbar-ac) >= (currentbar-ac)/2 then begin
   buy("AH-L" )next bar at market;
   DB=DB+1;
   AB=1;
   end;
if DS<=2 and c < AL  and countif(O>C,currentbar-ac) >= (currentbar-ac)/2   then begin
   sellshort("AL-L")  next bar at market;
   DS=DS+1;
   AS=1;
   end;
end;

if mp>0 and ( barssinceentry>2  ) and AS=0 then
  sell("L-1")   next bar at minlist(l[barssinceentry+1],l[barssinceentry]) stop;
if mp<0 and ( barssinceentry>2  ) and AB= 0 then
  buytocover("S-1")  next bar at maxlist(h[barssinceentry+1],h[barssinceentry]) stop;

if mp>0 and ( barssinceentry>2  ) and condition2   then begin
  sellshort ("RS")  next bar at minlist(l[barssinceentry+1],l[barssinceentry])  stop;
  DS=DS+1;
end;

if mp<0 and ( barssinceentry>2  ) and condition2 then begin
  buy ("RB") next bar at maxlist(h[barssinceentry+1],h[barssinceentry]) stop;
  DB=DB+1;
end;

if mp>0 and openpositionprofit+commission>= 2*(AH-NH)*bigpointvalue {and AB=0} then
  sell("L-2") from entry("NL-L")  next bar at market;
if mp<0 and openpositionprofit+commission>= 2*(NL-AL)*bigpointvalue {and AS=0} then
  buytocover("S-2") from entry("NH-S") next bar at market;


if mp>0 and dh >AH  then
  sell("L-3")   next bar at NH+barssinceentry stop;
if mp<0 and dl <AL then
  buytocover("S-3")   next bar at NL-barssinceentry stop;


if time >= calctime(sess1endtime,-4*barinterval) then begin
  sell("Time out L") next bar at market;
  buytocover("Time outS") next bar at market;
end;

setexitonclose;



另外最近有想要開團
multicharts團購策略台指期80支+海期25支海期內含
NQ:11支 共包含ACC、CDP、趨勢突破、價格突破、真實平均波動區間YM:5支 共包含均線ATR混合、SWING、高低點突破、
ES:7支 包含CCI移動平均、高低點突破、ADX
GC:1支、移動平均線混合SAR
CL:1支 RSI混合真實平均波動區間
共25支
大家一起share比較便宜
如果有興趣可以加我賴:cyberkey

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

本版積分規則

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

GMT+8, 24-3-29 07:17

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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