- 精华
- 0
- 在线时间
- 79 小时
- UID
- 74563
- 积分
- 154
- 帖子
- 19
- 阅读权限
- 40
- 注册时间
- 2011-10-27
- 最后登录
- 2014-3-1
- 精华
- 0
- UID
- 74563
- 积分
- 154
- 帖子
- 19
- 主题
- 9
- 阅读权限
- 40
- 注册时间
- 2011-10-27
- 最后登录
- 2014-3-1
|
你好,我参考其他网友在论坛的代码,稍微改动了一点点,用buy,sellshort替代A函数,这样就能够在图表上显示出下单箭头,但发现实际使用的时候无效,下单箭头无法出现,并且TimeSeconds和GetGlobalVar(10)的数值一直保持一致,请问是何原因,谢谢。- Params
-
- Numeric WaitTime(10); //预设等待时间,单位为秒,可调整
-
- Numeric ShiftUnit(3); //下单价格偏移量,可调整
-
- Vars
-
- Numeric Lots;
-
- Numeric NewPrice;
-
- Numeric TimeSeconds;
-
- Bool Openning;
-
- Begin
-
- If ( Q_Last == 0 || ( Date != Date[1] && High == Low ) ) Return; //如果未开盘,则直接返回
-
-
- If ( GetGlobalVar(10)==InvalidNumeric ) SetGlobalVar(10,0); //下单时间初始化
-
-
- TimeSeconds=Value(Left(TimeToString(CurrentTime),2))*3600 //记录系统当前时间,转化为秒数
-
- +Value(Mid(TimeToString(CurrentTime),3,2))*60
-
- +Value(Right(TimeToString(CurrentTime),2));
-
- PlotNumeric("TimeSeconds",TimeSeconds);
- PlotNumeric("GetGlobalVar(10)",GetGlobalVar(10));
- PlotNumeric("aa",TimeSeconds-GetGlobalVar(10));
- If ( TimeSeconds-GetGlobalVar(10)<WaitTime ) Return; //如果发单后等待时间小于WaitTime,则返回
-
-
- Openning = Q_Last > Q_LowerLimit && Q_Last < Q_UpperLimit; //停板情况下不允许建仓
-
- If ( MarketPosition==0 )
-
- {
-
- Lots=1;
-
-
-
- If (Close[1]>Close[2] )
-
- {
-
- NewPrice=Q_AskPrice+ShiftUnit*MinMove*PriceScale; //计算开仓价格
-
- // A_SendOrder(Enum_Buy,Enum_Entry,Lots,NewPrice);
- Buy(1,o);
-
- SetGlobalVar(10,TimeSeconds); //记录下单时间
-
- Return;
-
- }
-
-
- If ( Close[1]<Close[2])
-
- {
-
- NewPrice=Q_BidPrice-ShiftUnit*MinMove*PriceScale;
-
- // A_SendOrder(Enum_Sell,Enum_Entry,Lots,NewPrice);
- SellShort(1,o);
-
- SetGlobalVar(10,TimeSeconds);
-
- }
-
- Return;
-
- }
-
-
- If ( MarketPosition>0 && Close[1]<Close[2] )
-
- {
-
- NewPrice=Q_BidPrice-ShiftUnit*MinMove*PriceScale;
-
- // A_SendOrder(Enum_Sell,Enum_Exit,A_BuyPosition,NewPrice);
- Sell(1,o);
-
- SetGlobalVar(10,TimeSeconds);
-
- }
-
-
- If ( MarketPosition<0 && Close[1]>Close[2] )
-
- {
-
- NewPrice=Q_AskPrice+ShiftUnit*MinMove*PriceScale;
-
- // A_SendOrder(Enum_Buy,Enum_Exit,A_SellPosition,NewPrice);
- BuyToCover(1,o);
-
- SetGlobalVar(10,TimeSeconds);
-
- }
-
- End
复制代码 |
|