以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  请将下面TRADESTATION的资金管理代码改成金字塔的代码  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=7545)

--  作者:solarhe2006
--  发布时间:2011/8/15 21:18:23
--  请将下面TRADESTATION的资金管理代码改成金字塔的代码
資金管理很難嗎?只要在你的系統裡面加上下面幾行程式就可以了.

 请将下面TRADESTATION的资金管理代码改成金字塔的代码:

inputs:  rskAmt(0.02), StartEquity(30000) ; 
Vars: marketRisk(0), AccountEquity(0), NumContracts(0);

marketRisk = StdDev(Close,30)*BigPointValue*3;
AccountEquity = StartEquity + NetProfit;
NumContracts = (AccountEquity * rskAmt) / MarketRisk;


NumContracts = MaxList( intportion(NumContracts) ,1);

 

if buy condition

          Buy numContracts shares next bar at xxx price;

 

if sell condition 
           SellShort numContracts shares next bar at xxx price;

[此贴子已经被作者于2011-8-15 21:21:55编辑过]

--  作者:fly
--  发布时间:2011/8/16 9:12:31
--  

Intpart(Tasset/(Close*Multiplier*MarginRatio));//开仓手数---Multiplier是交易单位,系统自带函数;MarginRatio是保证金比率,需要自己设定

 

如果想使用实际资金的30%来开仓,以IF08为例,可设置成如下:

num:=Intpart((0.3*Tasset)/(Close*Multiplier*0.18));

 

if buycon then buy(holding=0,num,market);

if sellcon and holding>0 then sell(1,0,market);