疑似考虑周三过夜费的均价计算代码

void 计算均价( double & BUYavg,double & SELLavg)
{
  double    BMV = 0.0;
  double    Blots = 0.0;
  double    SMV = 0.0;
  double    Slots = 0.0;
  int       i;
  int       CMD;
  double    lots;
 double     Bopen;
 double     Bday;
 double     临_do_3;
 double     Sopen;
 double     Sday;
 double     临_do_6;

 double 多过夜 = SymbolInfoDouble(NULL,38) ;//疑似SYMBOL_SWAP_LONG
 double 空过夜 = SymbolInfoDouble(NULL,39) ;//疑似SYMBOL_SWAP_SHORT
 for (i=OrdersTotal() - 1 ; i >= 0 ; i --)
 {
   if ( !(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) || OrderMagicNumber() != MagicNumber 
       || OrderSymbol() != Symbol() )   continue;
   CMD  = OrderType() ;
   lots = OrderLots() ;
   if ( CMD == 0 )
   {
     if ( SymbolInfoInteger(NULL,37) >= 3 )//疑似SYMBOL_SWAP_ROLLOVER3DAYS?
     {
       Bopen = OrderOpenPrice();
     }
     else //
     {
       Bday = 0.0;
       //这是肯定的呀?
       if ( TimeCurrent() - OrderOpenTime()>0.0 )
       {
         临_do_3 = ((TimeCurrent() - OrderOpenTime()) / 5.0) * 7.0;// 5和7含义不清楚
         Bday = 临_do_3 / 86400.0;//60sec*60min*24=86400
       }
       else//
       {
         Bday = 0.0;
       }
       Bopen = OrderOpenPrice() - Bday * 多过夜 * Point;// swap费用
     }
     BMV   += Bopen * lots ; //量积
     Blots += lots ;//手数之和
   }
   //-------------------------------------------------
   if ( CMD != 1 )   continue;
   
   if ( SymbolInfoInteger(NULL,37) >= 3 )//疑似SYMBOL_SWAP_ROLLOVER3DAYS?
   {
     Sopen = OrderOpenPrice();
   }
   else
   {
     Sday = 0.0;
     if ( TimeCurrent() - OrderOpenTime()>0.0 )
     {
       临_do_6 = ((TimeCurrent() - OrderOpenTime()) / 5.0) * 7.0;
       Sday = 临_do_6 / 86400.0;
     }
     else
     {
       Sday = 0.0;
     }
     Sopen = Sday * 空过夜 * Point + OrderOpenPrice();
   }
   SMV   += Sopen * lots;
   Slots += lots ;
   
 }
 if ( Blots>0.0 )BUYavg  = BMV / Blots ;
 if ( Slots>0.0 )SELLavg = SMV / Slots ;
 
}
本博客所有文章如无特别注明均为原创。作者:天泓评测
分享到:更多

相关推荐

发表评论

路人甲 表情
Ctrl+Enter快速提交

网友评论(0)