以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  如何取得某个预警自己的浮动盈亏和平仓盈亏?  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=85306)

--  作者:cathero2001
--  发布时间:2015/9/16 23:23:17
--  如何取得某个预警自己的浮动盈亏和平仓盈亏?
老师,您好,

请问,如何取得某个预警自己的浮动盈亏和平仓盈亏?

谢谢

--  作者:jinzhe
--  发布时间:2015/9/17 8:47:22
--  

后台交易吗?

在代码里面加上

oo:topenprofit;

nn:tnumprofit(1);

 

然后用stkindi引用OO和NN


--  作者:cathero2001
--  发布时间:2015/9/17 9:57:40
--  
对的,后台交易。
topenprofit是获取整个账户的浮动盈亏吧,而不是当前预警的。比如我账户里同时在交易3个品种(分别用3个预警),topenprofit获取的是3个品种浮动盈亏的总和,而不是单独品种的。

tnumprofit(1)是获取最近一次平仓交易的盈亏,也不一定是当前预警的平仓盈亏啊。


--  作者:jinzhe
--  发布时间:2015/9/17 10:04:56
--  

后台里面的topenprofit和tnumprofit都是指当前预警的数值,账户的数值你要用账户函数去获取

你开3个预警这3个预警的topenprofit和tnumprofit是独立的

[此贴子已经被作者于2015/9/17 10:05:25编辑过]

--  作者:cathero2001
--  发布时间:2015/9/17 10:06:41
--  
好的,谢谢,可能我程序里没用对。


--  作者:cathero2001
--  发布时间:2015/9/17 10:09:51
--  
不过tnumprofit(1)只是获取最近一次的平仓盈亏,能否获取某一预警当天(夜盘开始)的平仓盈亏?


--  作者:jinzhe
--  发布时间:2015/9/17 10:22:13
--  

if time=closetime(0) then extgbdataset(\'ss\',TACCOUNT(30));

if time<>closetime(0) then extgbdataset(\'ss\',TACCOUNT(30));

 

tt:extgbdata(\'ss\');

tt的值就是当天整体账户的平仓盈亏


--  作者:cathero2001
--  发布时间:2015/9/17 11:03:38
--  
我不需要整体账户的盈亏,我需要的是 单独一个预警当天到现在的盈亏,谢谢。
--  作者:jinzhe
--  发布时间:2015/9/17 11:13:57
--  

GLOBALVARIABLE:tt=0,nn=0;

 

if 平多条件 and 持仓判断 then begin

    tsell(1,0,mkt);

   if time<>tt then begin

     tt:=time;

     nn:=nn+tnumprofit(1);

   end

end

 

if 平空条件 and 持仓判断 then begin

    tsellshort(1,0,mkt);

   if time<>tt then begin

     tt:=time;

     nn:=nn+tnumprofit(1);

   end

end

 

if time=timeclose(0) then begin

    tt:=0;

    nn:=0;

end

 

nn就是一天的累加值