Rss & SiteMap

金字塔客服中心 - 专业程序化交易软件提供商 http://www.weistock.com/bbs/

专业程序化软件提供商
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:老师,设置为轮询1秒模式,平仓想设为走完1根K线但提前1秒下单?开仓想保持信号出现马上下单。麻烦老师帮下忙!谢了

1楼
panjia1000 发表于:2017/9/13 11:02:23
//老师,设置为轮询1秒模式,平仓想设为走完1根K线但提前1秒下单?开仓想保持信号出现马上下单
DMA5: MA(high,5);                                                  
KMA5: MA(low,5);                                                  
DMA10:MA(high,10);                                                
KMA10:MA(Low,10);                                                
B1:=CROSS(DMA5,DMA10);
B2:=CROSS(KMA10,KMA5);
if date<>ref(date,1) then begin
count1:=1;
count2:=1;
end
lots:=1;
//亏损平仓(想设为走完1根K线但提前1秒下单)
if holding>0  and  l<=ENTERPRICE-10  then  begin
sell(1,holding,NEXTOPEN),IGNORECHECKPRICE;
 end
if holding<0  and  h>=ENTERPRICE+10   then   begin
sellshort(1,holding,NEXTOPEN),IGNORECHECKPRICE;
 end
//开仓(设为固定1秒轮询想保持信号出现马上下单)
if  holding=0  and count2=1 then  begin
if B1 then   begin
 buy(1,lots,limitr,open),IGNORECHECKPRICE;
 HigherAfterEntry:=enterprice;
 LowerAfterEntry:=enterprice;
end
 end
 if holding=0  and count2=1  then   begin
if B2 then
  begin
  buySHORT(1,lots,limitr,open),IGNORECHECKPRICE;
 HigherAfterEntry:=enterprice;
 LowerAfterEntry:=enterprice;
   end
end 
 //盈利平仓(想设为走完1根K线但提前1秒下单)
 if holding>0 and enterbars>0  then  begin
 if  enterbars>=1  and HigherAfterEntry>=enterprice*1  then  begin
 price:=EnterPrice+(HigherAfterEntry-EnterPrice)*1;
 if low<=price then  begin
sell(1,holding,NEXTOPEN),IGNORECHECKPRICE;
count2:=1;
end
 end;
  end;
 if holding<0 and enterbars>0  then  begin
 if  enterbars>=1    and lowerAfterEntry<=enterprice*1   then begin
 price:=EnterPrice - (EnterPrice-LowerAfterEntry)*1;
 if high>=price then  begin
 sellshort(1,holding,NEXTOPEN),IGNORECHECKPRICE;
  count2:=1;
  end;
2楼
wenarm 发表于:2017/9/13 11:28:03

平仓条件中加入abb:=(time0-timetot0(dynainfo(207))<=tq) or not(islastbar); 这个判断、

提前下单的范例代码,tq是提前的时间没

ma5:=ma(c,5);
ma10:=ma(c,10);
input:tq(5,3,60,1);//提前的秒数,最多提前60秒

abb:=(time0-timetot0(dynainfo(207))<=tq) or not(islastbar);

if abb then begin
  if holding>0 and ma5<ma10 then sell(1,1,thisclose);
  if holding<0 and ma5>ma10 then sellshort(1,1,thisclose);
  if holding=0 and ma5>ma10 then buy(1,1,thisclose);
  if holding=0 and ma5<ma10 then buyshort(1,1,thisclose);

end

3楼
panjia1000 发表于:2017/9/13 19:38:49

//要设置为轮询1秒模式,平仓想设为走完1根K线但提前1秒下单,开仓想及时下单
DMA5: MA(high,5);                                                  
KMA5: MA(low,5);                                                  
DMA10:MA(high,10);                                                
KMA10:MA(Low,10);                                                
B1:=CROSS(DMA5,DMA10);
B2:=CROSS(KMA10,KMA5);
if date<>ref(date,1) then begin
count1:=1;
count2:=1;
end
lots:=1;

p2:=if(islastbar,dynainfo(207),time);
p3:=time0-timetot0(p2),linethick0;


 

//亏损平仓

if holding>0  and  l<=ENTERPRICE-10 AND HOLDING>0 and p3<=1,0,limitr,jgs-hdk then  begin
sell(1,holding,NEXTOPEN),IGNORECHECKPRICE;
 
 end
if holding<0  and  h>=ENTERPRICE+10 AND HOLDING<0 and p3<=1,0,limitr,jgx+hdd then   begin
sellshort(1,holding,NEXTOPEN),IGNORECHECKPRICE;
 end
//开仓
if  holding=0  and count2=1 then  begin
if B1 then   begin
 buy(1,lots,limitr,open),IGNORECHECKPRICE;
 HigherAfterEntry:=enterprice;
 LowerAfterEntry:=enterprice;
end
 end
 if holding=0  and count2=1  then   begin
if B2 then
  begin
  buySHORT(1,lots,limitr,open),IGNORECHECKPRICE;
 HigherAfterEntry:=enterprice;
 LowerAfterEntry:=enterprice;
   end
end 
 //盈利平仓
 if holding>0 and enterbars>0  then  begin
 if  enterbars>=1  and HigherAfterEntry>=enterprice*1 AND HOLDING>0 and p3<=5,0,limitr,jgs-hdk then  begin
 price:=EnterPrice+(HigherAfterEntry-EnterPrice)*1;
 if low<=price then  begin
sell(1,holding,NEXTOPEN),IGNORECHECKPRICE;
count2:=1;
end
 end;
  end;
 if holding<0 and enterbars>0  then  begin
 if  enterbars>=1    and lowerAfterEntry<=enterprice*1 AND HOLDING<0 and p3<=5,0,limitr,jgx+hdd  then begin
 price:=EnterPrice - (EnterPrice-LowerAfterEntry)*1;
 if high>=price then  begin
 sellshort(1,holding,NEXTOPEN),IGNORECHECKPRICE;
  count2:=1;
  end;
 end
 end;

4楼
wenarm 发表于:2017/9/13 21:10:31
不对。
DMA5: MA(high,5);                                                  
KMA5: MA(low,5);                                                  
DMA10:MA(high,10);                                                
KMA10:MA(Low,10);                                                
B1:=CROSS(DMA5,DMA10);
B2:=CROSS(KMA10,KMA5);
if date<>ref(date,1) then begin
count1:=1;
count2:=1;
end
abb:=(time0-timetot0(dynainfo(207))<=1) or not(islastbar);
lots:=1;
//亏损平仓(想设为走完1根K线但提前1秒下单)
if holding>0  and  l<=ENTERPRICE-10 and abb then  begin
 sell(1,holding,NEXTOPEN),IGNORECHECKPRICE;
end
if holding<0  and  h>=ENTERPRICE+10  and abb then   begin
 sellshort(1,holding,NEXTOPEN),IGNORECHECKPRICE;
end
//开仓(设为固定1秒轮询想保持信号出现马上下单)
if  holding=0  and count2=1 then  begin
 if B1 then   begin
   buy(1,lots,limitr,open),IGNORECHECKPRICE;
   HigherAfterEntry:=enterprice;
   LowerAfterEntry:=enterprice;
 end
end
if holding=0  and count2=1  then   begin
 if B2 then begin
    buySHORT(1,lots,limitr,open),IGNORECHECKPRICE;
   HigherAfterEntry:=enterprice;
   LowerAfterEntry:=enterprice;
   end
end 
 //盈利平仓(想设为走完1根K线但提前1秒下单)
 if holding>0 and enterbars>0  then  begin
  if  enterbars>=1  and HigherAfterEntry>=enterprice*1  then  begin
   price:=EnterPrice+(HigherAfterEntry-EnterPrice)*1;
   if low<=price and abb then  begin
   sell(1,holding,NEXTOPEN),IGNORECHECKPRICE;
   count2:=1;
  end
  end
 end
 if holding<0 and enterbars>0  then  begin
  if  enterbars>=1    and lowerAfterEntry<=enterprice*1   then begin
   price:=EnterPrice - (EnterPrice-LowerAfterEntry)*1;
   if high>=price and abb then  begin
    sellshort(1,holding,NEXTOPEN),IGNORECHECKPRICE;
     count2:=1;
    end
   end
 end
5楼
panjia1000 发表于:2017/9/14 11:13:47

谢谢老师,谢谢老师

共5 条记录, 每页显示 10 条, 页签: [1]


Powered By Dvbbs Version 8.3.0
Processed in 0.01563 s, 3 queries.