老师 我想写一个模型
从当日第一根K线算起上涨50点做多 下跌50点做空
当持有多单时,自持有多单之后的高点回落50点平多翻空
当持有空单时,自持有空单之后的低点上涨50点平空翻多
1455分平掉所有持仓
我自己写的 但是执行起来不对 一个信号都没有 希望老师能按照我上面的意思帮我写一个
variable:H1=0; //定义变量高点
variable:L1=0; //定义变量低点
If DATE<>ref(DATE,1) then BEGIN
H1:=High;
L1:=LOW;
end
If DATE=ref(DATE,1) then BEGIN
H1:=Max(H1,HIGH);
L1:=Min(L1,LOW);
end
If TIME<145500 then BEGIN
t1:=(H1-LOW)>=50;
Sell(t1,1,H1-50); // 先写的多头平仓 平仓价为比高点低50的价
L1:=LOW; //重新记录低点
end
If holding=0 then BEGIN //多单开仓
t3:=(HIGH-L1)>=50;
Buy(t3,1,L1+50);
H1:=High;
end
variable:hh=0,ll=0;
o1:=valuewhen(date<>ref(date,1),o);
if c>o1+50then begin
buy(holding=0,1,market);
hh:=h;
end
if h>hh then hh:=h;
if hh-c>50 then begin
sell(holding>0,0,market);
buyshort(holding=0,1,market);
end
if c<o1-50 then begin
buyshort(holding=0,1,market);
ll:=l;
end
if l<ll then ll:=l;
if c-ll>50 then BEGIN
sellshort(holding<0,0,market);
buy(holding=0,1,market);
end