- 精华
- 0
- 在线时间
- 75 小时
- UID
- 114998
- 积分
- 73
- 帖子
- 40
- 阅读权限
- 30
- 注册时间
- 2013-1-20
- 最后登录
- 2020-2-25
- 精华
- 0
- UID
- 114998
- 积分
- 73
- 帖子
- 40
- 主题
- 13
- 阅读权限
- 30
- 注册时间
- 2013-1-20
- 最后登录
- 2020-2-25
|
ample 发表于 2013-8-28 14:29
是否设置了交易助手,那些委托是交易助手发出来的?
另外,监控器中系统仓表示的就是图表仓位,不知道楼 ...
没有设置交易助手。为了方便,我还是把公式都贴上来吧,麻烦看看是哪里出的问题,谢谢。- Params
- Bool bInitStatus(False); // 初始化标志,修改初始仓位时需设置为True
- Numeric EveryLots(1); // 每次交易数量手数
- Numeric LongEntryPrice(4); // 开多仓的触发价格
- Numeric LongExitPrice(5); // 平多仓的触发价格
- Numeric ShortEntryPrice(5); // 开空仓的触发价格
- Numeric ShortExitPrice(4); // 平空仓的触发价格
- Numeric LongStartLots(0); // 多仓的初始仓位(手数),必须是EveryLots的倍数
- Numeric LongEndLots(2); // 多仓的最大仓位(手数),必须是EveryLots的倍数
- Numeric ShortStartLots(0); // 空仓的初始仓位(手数),必须是EveryLots的倍数
- Numeric ShortEndLots(2); // 空仓的最大仓位(手数),必须是EveryLots的倍数
- Numeric OffsetPoint(1); // 委托价格的偏移值(点数)
- Vars
- Numeric SpreadUpper;
- Numeric SpreadLower;
- Numeric longPosition;
- Numeric shortPosition;
- Bool bLongEntryCon;
- Bool bShortEntryCon;
- Bool bLongExitCon;
- Bool bShortExitCon;
- Bool bTimeCon;
- Numeric Data0Lots(1);
- Numeric Data1Lots(1);
- Begin
- longPosition = GetGlobalVar(0);
- shortPosition = GetGlobalVar(1);
- If (BarStatus == 0)
- {
- If(longPosition == InvalidNumeric || bInitStatus)
- {
- longPosition = LongStartLots;
- SetGlobalVar(0,longPosition);
- }
- If(shortPosition == InvalidNumeric || bInitStatus)
- {
- shortPosition = ShortStartLots;
- SetGlobalVar(1,shortPosition);
- }
- }Else If(BarStatus == 2 && A_AccountID!="")
- {
- If(EveryLots < 1) Return;
- If(Data0.Q_AskPrice <= 0 || Data0.Q_BidPrice <= 0 || Data1.Q_AskPrice <= 0 || Data1.Q_BidPrice <= 0) Return;
- If(Data0.Q_BidPrice == Data0.Q_UpperLimit || Data0.Q_AskPrice == Data0.Q_LowerLimit) Return;
- If(Data1.Q_BidPrice == Data1.Q_UpperLimit || Data1.Q_AskPrice == Data1.Q_LowerLimit) Return;
- SpreadUpper = Round(Data0.Q_AskPrice-Data1.Q_BidPrice,1);
- SpreadLower = Round(Data0.Q_BidPrice-Data1.Q_AskPrice,1);
- FileAppend("E:\\低波动率套利"+Symbol+".txt",Text(CurrentTime)+"\t"+"SpreatUpper="+Text(SpreadUpper)+"\t"+"SpreadLower="+Text(SpreadLower));
- bTimeCon = true;//Time>0.0903 ;//And (Time<0.1127 Or Time>0.1333) And Time<0.1456;
- bLongEntryCon = (SpreadUpper<=LongEntryPrice) && (Data0.Q_AskVol>=EveryLots && Data1.Q_BidVol>=EveryLots);
- bLongExitCon = (SpreadLower>=LongExitPrice) && (Data1.Q_AskVol>=EveryLots && Data0.Q_BidVol>=EveryLots);
- bShortEntryCon = (SpreadLower>=ShortEntryPrice) && (Data1.Q_AskVol>=EveryLots && Data0.Q_BidVol>=EveryLots);
- bShortExitCon = (SpreadUpper<=ShortExitPrice) && (Data0.Q_AskVol>=EveryLots && Data1.Q_BidVol>=EveryLots);
- If(((bLongExitCon And bTimeCon And longPosition>0) Or longPosition>LongEndLots ))
- {
- Data0.A_SendOrder(Enum_Sell,Enum_Exit,Data0Lots,Data0.Q_BidPrice-OffsetPoint*MinMove*PriceScale);
- Data1.A_SendOrder(Enum_Buy,Enum_Exit,Data1Lots,Data1.Q_AskPrice+OffsetPoint*MinMove*PriceScale);
- SetGlobalVar(0,longPosition - EveryLots);
- }
- If(((bShortExitCon And bTimeCon And shortPosition>0) Or shortPosition>ShortEndLots ))
- {
- Data0.A_SendOrder(Enum_Buy,Enum_Exit,Data0Lots,Data0.Q_AskPrice+OffsetPoint*MinMove*PriceScale);
- Data1.A_SendOrder(Enum_Sell,Enum_Exit,Data1Lots,Data1.Q_BidPrice-OffsetPoint*MinMove*PriceScale);
- SetGlobalVar(1,shortPosition - EveryLots);
- }
- //
- If((bLongEntryCon And bTimeCon And longPosition<LongEndLots))
- {
- Data0.A_SendOrder(Enum_Buy,Enum_Entry,Data0Lots,Data0.Q_AskPrice+OffsetPoint*MinMove*PriceScale);
- Data1.A_SendOrder(Enum_Sell,Enum_Entry,Data1Lots,Data1.Q_BidPrice-OffsetPoint*MinMove*PriceScale);
- SetGlobalVar(0,longPosition + EveryLots);
- }
-
- If(( bShortEntryCon And bTimeCon And shortPosition<ShortEndLots))
- {
- Data0.A_SendOrder(Enum_Sell,Enum_Entry,Data0Lots,Data0.Q_BidPrice-OffsetPoint*MinMove*PriceScale);
- Data1.A_SendOrder(Enum_Buy,Enum_Entry,Data1Lots,Data1.Q_AskPrice+OffsetPoint*MinMove*PriceScale);
- SetGlobalVar(1,shortPosition + EveryLots);
- }
- }
- Commentary("多头仓位="+Text(longPosition));
- Commentary("空头仓位="+Text(shortPosition));
- End
复制代码 |
|