以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  图表改后台  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=95112)

--  作者:rockyan
--  发布时间:2016/3/25 8:57:56
--  图表改后台

请问下述图表,可以改后台吗?

 

variable:sumwealth=0;

variable:zichan=0;
ma10:=ma(c,5);
ma25:=ma(c,25);
sxf:=0.21/100;//手续费0.21%

手数:=max(0,floor((zichan-ref(zichan,barslast(date=1160315)))/360000));
if holding>0 and ma10<ma25 then begin
 sell(1,holding,thisclose);
 sumwealth:=sumwealth+holding*c*300*(1-sxf);//卖出时减去交易额
end
if holding<0 and ma10>ma25 then begin
 sellshort(1,holding,thisclose);
 sumwealth:=sumwealth-holding*c*300*(1+sxf);//买入时加上交易额
end
if holding=0 and ma10>ma25 and 手数>0 then begin
 buy(1,手数,thisclose);
 sumwealth:=sumwealth-手数*c*300*(1+sxf);
end
if holding=0 and ma10<ma25 and 手数>0 then begin
 buyshort(1,手数,thisclose);
 sumwealth:=sumwealth+手数*c*300*(1-sxf);
end

zichan:=sumwealth+holding*c*300-abs(holding)*c*300*sxf;


--  作者:jinzhe
--  发布时间:2016/3/25 9:05:39
--  

globalvariable:sumwealth=0;

globalvariable:zichan=0;
ma10:=ma(c,5);
ma25:=ma(c,25);
sxf:=0.21/100;//手续费0.21%

手数:=max(0,floor((zichan-ref(zichan,barslast(date=1160315)))/360000));
if tbuyholding(0)>0 and ma10<ma25 then begin
 sumwealth:=sumwealth+tbuyholding(0)*c*300*(1-sxf);//卖出时减去交易额
 tsell(1,0,mkt);
end
if tsellholding(0)>0 and ma10>ma25 then begin
  sumwealth:=sumwealth-tsellholding(0)*c*300*(1+sxf);//买入时加上交易额
 tsellshort(1,0,mkt);

end
if tbuyholding(0)=0 and ma10>ma25 and 手数>0 then begin
 tbuy(1,手数,mkt);
 sumwealth:=sumwealth-手数*c*300*(1+sxf);
end
if tsellholding(0)=0 and ma10<ma25 and 手数>0 then begin
 tbuyshort(1,手数,mkt);
 sumwealth:=sumwealth+手数*c*300*(1-sxf);
end

if tbuyholding(0)>0 then zichan:=sumwealth+tbuyholding(0)*c*300-tbuyholding(0)*c*300*sxf;

if tsellholding(0)>0 then zichan:=sumwealth+tsellholding(0)*c*300-tsellholding(0)*c*300*sxf;


--  作者:rockyan
--  发布时间:2016/3/25 12:20:45
--  

tbuyholding 指的是当前实际帐户里的当前品种的实际持仓,无法分辨是否当前策略产生的持仓,会把其他策略的单子平调的,有其他的方式代替吗?


--  作者:jinzhe
--  发布时间:2016/3/25 13:25:23
--  
后台无法区分当前账户里面的持仓是哪一个策略开的
--  作者:rockyan
--  发布时间:2016/3/25 14:52:03
--  
所以要写其他程序代替啊
--  作者:rockyan
--  发布时间:2016/3/25 14:53:52
--  

实际上,平仓语句里的holding,就是上次开仓数

在后台里能表示上次开仓数就行了


--  作者:fly
--  发布时间:2016/3/25 15:08:16
--  

用全局变量,记录每次的开仓手数。

 

后台全局变量示例如下:

【金字塔使用技巧】----后台轮询,如何记录变量在最后一周期内的最大最小及开盘值

ma5:=ma(c,5);

if islastbar then

 begin

 //在新一根K线上记录初始化

  if barpos>extgbdata(\'t\') then

   begin

   extgbdataset(\'FIR\',ma5);//记录开盘值

   extgbdataset(\'MAX1\',ma5);//记录最大

   extgbdataset(\'MIN1\',ma5);//记录最小

   extgbdataset(\'t\',barpos);

   end

  

  if barpos=extgbdata(\'t\') then

   begin

   if ma5>extgbdata(\'MAX1\') THEN extgbdataset(\'MAX1\',ma5);

   if ma5<extgbdata(\'MIN1\') THEN extgbdataset(\'MIN1\',ma5);

   end

  end


--  作者:admin
--  发布时间:2016/3/25 19:42:11
--  

http://www.weistock.com/bbs/dispbbs.asp?boardid=16&Id=57075

22、如何在后台程序化交易里一个品种的多个策略的交易