Function that returns the number of consecutive wins

Aug 24, 2016 at 05:23
452浏览
1 Replies
JHenrique
forex_trader_318221
会员从Apr 07, 2016开始   32帖子
Aug 24, 2016 at 05:23
Hi guys!

I’m looking for a function that returns the number of consecutive profitable trades until X victories. When the number of profitable trades hits the X value, so the count is restarted.

If someone can help me... thx!!!
forex_trader_25447
会员从Dec 21, 2010开始   131帖子
Aug 24, 2016 at 14:38
This program return numbers of winners (nWin)
from last accepted loss in current symbol :

// program global variable
double nWin;

void Profit() // Return nWin
{ datetime LastTimeLOSS=0;
  j=0;
  while ( j<OrdersHistoryTotal() )
  { if ( OrderSelect(j,SELECT_BY_POS,MODE_HISTORY) )
      if ( OrderSymbol()==_Symbol )
        if ( OrderType()==OP_BUY || OrderType()==OP_SELL )
        { if ( OrderCloseTime()>LastTimeLOSS && OrderProfit()<0.0 )
            LastTimeLOSS=OrderCloseTime();
        }
    j++; }
  if ( OrderSelect(0,SELECT_BY_POS,MODE_HISTORY) )
    if ( LastTimeLOSS==0 ) LastTimeLOSS=OrderOpenTime();
    else {}
  else LastTimeLOSS=TimeCurrent();

  j=0; CurrentPROFIT=0; nWin=0;
  while ( j<OrdersHistoryTotal() )
  { if ( OrderSelect(j,SELECT_BY_POS,MODE_HISTORY) )
      if ( OrderType()==OP_BUY || OrderType()==OP_SELL )
        if ( ( OrderCloseTime()==LastTimeLOSS && OrderSymbol()!=_Symbol ) ||
               OrderCloseTime()>LastTimeLOSS ) nWin++;
    j++;
  }
}
登录 / 注册 to comment
You must be connected to Myfxbook in order to leave a comment
*商业用途和垃圾邮件将不被容忍,并可能导致账户终止。
提示:发布图片/YouTube网址会自动嵌入到您的帖子中!
提示:键入@符号,自动完成参与此讨论的用户名。