为了计算当天的结算单 [开拓者 TB]
- 咨询内容:
Vars
Numeric nCount0;
Numeric i0;
Numeric nEntryFlag0;
Numeric nbuyFlag0;
Numeric nbuyexitlot0;
Numeric mycapital0;
Numeric yingkuiprice;
Numeric todaycapitalnun;
Begin
If(BarStatus==2)
{
nCount0 = Data0.A_GetOrderCount();
If(nCount0>=1)
{
For i0 = 0 To nCount0
{
nEntryFlag0 = A_OrderEntryOrExit(i0);
nbuyFlag0 = A_OrderBuyOrSell(i0);
If(nEntryFlag0 == Enum_Exit() && nbuyFlag0 == Enum_Buy)
{
nbuyexitlot0 = A_OrderFilledLot;
if(Data0.A_BuyPosition>Data0.A_SellPosition) mycapital0=(Data0.Q_PreSettlePrice-Data0.A_OrderFilledPrice)*Data0.ContractUnit*nbuyexitlot0+(Data0.Q_AvgPrice-Data0.Q_PreSettlePrice)*Data0.ContractUnit*(Data0.A_BuyPosition-Data0.A_SellPosition-nbuyexitlot0);
If(Data0.A_SellPosition>=Data0.A_BuyPosition) mycapital0=(Data0.Q_PreSettlePrice-Data0.A_OrderFilledPrice)*Data0.ContractUnit*nbuyexitlot0+(Data0.Q_PreSettlePrice-Data0.Q_AvgPrice)*Data0.ContractUnit*(Data0.A_SellPosition-Data0.A_BuyPosition-nbuyexitlot0);
}Else If(nEntryFlag0 == Enum_Exit() && nbuyFlag0 == Enum_sell)
{
nbuyexitlot0 = A_OrderFilledLot;
if(Data0.A_BuyPosition>Data0.A_SellPosition) mycapital0=(Data0.A_OrderFilledPrice-Data0.Q_PreSettlePrice)*Data0.ContractUnit*nbuyexitlot0+(Data0.Q_AvgPrice-Data0.Q_PreSettlePrice)*Data0.ContractUnit*(Data0.A_BuyPosition-Data0.A_SellPosition-nbuyexitlot0);
If(Data0.A_SellPosition>=Data0.A_BuyPosition) mycapital0=(Data0.A_OrderFilledPrice-Data0.Q_PreSettlePrice)*Data0.ContractUnit*nbuyexitlot0+(Data0.Q_PreSettlePrice-Data0.Q_AvgPrice)*Data0.ContractUnit*(Data0.A_SellPosition-Data0.A_BuyPosition-nbuyexitlot0);
}
}
If(Data0.A_TodayBuyPosition>0 Or Data0. A_TodaySellPosition>0)
{
if(Data0.A_BuyPosition>Data0.A_SellPosition) mycapital0=(Data0.Q_AvgPrice-Data0.A_OrderFilledPrice)*Data0.ContractUnit*Data0.A_todayBuyPosition+(Data0.Q_AvgPrice-Data0.Q_PreSettlePrice)*Data0.ContractUnit*(Data0.A_BuyPosition-Data0.A_SellPosition-Data0.A_todayBuyPosition);
If(Data0.A_SellPosition>Data0.A_BuyPosition) mycapital0=(Data0.A_OrderFilledPrice-Data0.Q_AvgPrice)*Data0.ContractUnit*Data0.A_todaySellPosition+(Data0.Q_PreSettlePrice-Data0.Q_AvgPrice)*Data0.ContractUnit*(Data0.A_SellPosition-Data0.A_BuyPosition-Data0.A_todaySellPosition);
}
}Else If(Data0.A_BuyPosition>0 Or Data0.A_SellPosition>0)
{
if(Data0.A_BuyPosition>Data0.A_SellPosition) mycapital0=(Data0.Q_AvgPrice-Data0.Q_PreSettlePrice)*Data0.ContractUnit*(Data0.A_BuyPosition-Data0.A_SellPosition);
If(Data0.A_SellPosition>Data0.A_BuyPosition) mycapital0=(Data0.Q_PreSettlePrice-Data0.Q_AvgPrice)*Data0.ContractUnit*(Data0.A_SellPosition-Data0.A_BuyPosition);
}
yingkuiprice=mycapital0;
todaycapitalnun=A_PreviousEquity+A_TodayDeposit-A_TodayDrawing+yingkuiprice;
FileDelete("E:\\兴业日结单核对文档.txt");
FileAppend("E:\\兴业日结单核对文档.txt", "商品名称"+" "+"当日盈亏"+" "+"今开仓价"+" "+"今天结算价"+" "+"昨天结算价"+" "+"合约单位"+" "+"多仓"+" "+"空仓"+" "+"昨日结存"+" "+"当日入金"+" "+"当日出金"+" "+"当日盈亏"+" "+"当日结存"+" "+"总计");
FileAppend("E:\\兴业日结单核对文档.txt", Data0.SymbolName+" "+Text(mycapital0)+" "+Text(Data0.A_OrderFilledPrice)+" "+Text(Data0.Q_AvgPrice)+" "+Text(Data0.Q_PreSettlePrice)+" "+Text(Data0.ContractUnit)+" "+Text(Data0.A_Buyposition)+" "+Text(Data0.A_sellposition)+" "+Text(A_PreviousEquity)+" "+Text(A_TodayDeposit)+" "+Text(A_TodayDrawing)+" "+Text(yingkuiprice)+" "+Text(todaycapitalnun));
}
End
为了计算当天的结算单
为何编译能通过,但不能输出文档
请管理员或高手帮忙修改一下!谢谢
- TB技术人员:
我复制公式在自己的机器上运行,就一直是无响应。貌似是一个死循环跳不出来。
- TB客服: 应该是有逻辑错误
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 1145508240 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容