利用a函数没有顺利的读出帐户信息
老师您好,我想控制帐户总体的风险,利用a函数没有读到帐户的总权益、总保证金及可用资金,是哪里写出了问题?这段代码里有a函数读取资金情况的同时是用图表系统进行交易,这样是否可行,如果不可行应该怎么改进?Params Numeric FastLength(5);// 短期指数平均线参数 Numeric SlowLength(20);// 长期指数平均线参数 Numeric probability(30);// 概率 Numeric loss_ratio(3);// 损益比 Numeric exposure(0.05);// 风险敞口 Numeric Margin_Rate(0.15);// 保证金率 Numeric Override(10);// 倍率 Numeric average_loss(2000);// 平均亏损 Numeric i(1);// Vars Series<Numeric> AvgValue1; Series<Numeric> AvgValue2; Series<Numeric> TotalEquity; Series<Numeric> Margin;//当前品种保证金 Series<Numeric> lots; Series<Numeric> lot1; Series<Numeric> lot2; Series<Numeric> lot3; Series<Numeric> lot4;Events OnBar(ArrayRef<Integer> indexs) { AvgValue1 = AverageFC(Close,FastLength); AvgValue2 = AverageFC(Close,SlowLength); PlotNumeric(\"MA1\",AvgValue1); PlotNumeric(\"MA2\",AvgValue2); Margin=c*override*margin_rate; lot1=IntPart((A_FreeMargin(i)-A_CurrentEquity(i)/2)/Margin);//风险度小于0.5 lot3=IntPart(A_CurrentEquity(i)*exposure/average_loss);//风险小于0.05 lots=min(lot1,lot3); Commentary(\"总权益:\" + Text(A_CurrentEquity(i))); Commentary(\"可用资金:\" + Text(A_FreeMargin(i))); Commentary(\"总保证金\" + Text(A_TotalMargin(i))); Commentary(\"头寸1:\" + Text(lot1)); Commentary(\"头寸3\" + Text(lot3)); Commentary(\"保证金\" + Text(Margin)); If(MarketPosition <>1 && AvgValue1[1] > AvgValue2[1]) { //Buy(lots,Open); } If(MarketPosition <>-1 && AvgValue1[1] < AvgValue2[1]) { //SellShort(lots,Open); } }