- 金币:
-
- 奖励:
-
- 热心:
-
- 注册时间:
- 2013-9-6

|
|

楼主 |
发表于 2013-9-7 09:56
|
显示全部楼层
- // 股票下单助手,配合券商下单软件进行买入卖出操作
- // 可用来实现自动止损等操作
- // 适用于[istock]招商证券[/istock]全能版的最新版本,其他的通达信券商版本应该也可用
- #Run_By_Bar
- #MAINCHART
- #nodefaultoutput
- //买入
- extern 'Order.dll' int Buy1(String stkCode, int vol, float price, float slipPrice);
- //卖出
- extern 'Order.dll' int Sell1(String stkCode, int vol, float price, float slipPrice);
- extern 'Order.dll' String LastError(); // 上一个错误描述
- //取买入价
- extern 'Order.dll' float MyEntryPrice(String code);
- //盈利多少,返回盈亏百分比,例如盈利10%返回 10,亏损 15%返回 -15
- extern 'Order.dll' float MyProfit(String code);
- //当期持仓,0为无持仓,1为持仓
- extern 'Order.dll' float MyMarketPosition(String code);
- //持仓总量
- extern 'Order.dll' float MyCurrentContract(String code);
- //资金
- extern 'Order.dll' float MyCaptical(String code);
- //成本价
- extern 'Order.dll' float MyCost(String code);
- //可卖量
- extern 'Order.dll' float MyTradeAbleVol(String code);
- //未成交委托量buySellDirection=0买入 buySellDirection=1卖出
- extern 'Order.dll' float MyOpenOrderVol(String code, int buySellDirection);
- //撤单buySellDirection=0买入 buySellDirection=1卖出
- extern 'Order.dll' float CancelMyOrder(String code, int buySellDirection);
- //最后一根k线才进行操作
- if BarStatus == 2 Then begin
- //测试各种账户查询函数
- if MyMarketPosition(StkLabel) > 0 then begin
- Comment('盈利:', MyProfit(StkLabel), '%');
- Comment('持仓量:', MyCurrentContract(StkLabel));
- Comment('可卖量:', MyTradeAbleVol(StkLabel));
- Comment('买入价:', MyEntryPrice(StkLabel));
- Comment('成本金额:', MyCost(StkLabel));
- Comment('市值:', MyCaptical(StkLabel));
- end
- Else Begin
- Comment('当前股票无持仓');
- end
-
- // 测试买入 ,以最新价减8%买入
- if MyMarketPosition(StkLabel) == 0 Then begin
- // 如果已经有挂单,则先撤单
- if (MyOpenOrderVol(StkLabel,0) > 0) Then
- CancelMyOrder(StkLabel,0);
-
- if (buy1(StkLabel, 100, close-close*0.08, 0 )) then
- Comment(LastError());
- end
-
- end
-
复制代码 |
|
|