Code: Select all
LossTrades = 0;
LossCount=1;
int LossCountCount=1;
WinTrades = 0;
OverallProfit = 0;
for (int cc = 0; cc <= OrdersHistoryTotal(); cc++)
{
if (!OrderSelect(cc, SELECT_BY_POS, MODE_HISTORY) ) continue;
if (OrderSymbol() != Symbol() ) continue;
if (OrderMagicNumber() != MagicNumber) continue;
OverallProfit+= (OrderProfit() + OrderSwap() + OrderCommission() );
if (OrderProfit() > 0) WinTrades++;
if (OrderProfit() < 0) LossTrades++;
// End of the 'switch' body
if (OrderProfit() < 0) LossCountCount++;
if (OrderProfit() > 0) LossCountCount=1;
// GlobalVariableSet("longtrade"+Symbol(),0);
// GlobalVariableSet("shorttrade"+Symbol(),0);
// if (OrderProfit() < 0) {step=step+1;}
switch (LossCountCount) // Header of the operator 'switch'
{ // Start of the 'switch' body
case 1 : LossCount=1; // Variations..
case 2 : LossCount=1;
case 3 : LossCount=2;
case 4 : LossCount=3; // Here are 10 variations ..
case 5 : LossCount=4; // ..'case' presented, but, in general, ..
case 6 : LossCount=6; // ..the amount of variations..
case 7 : LossCount=9; // ..'case' is unlimited
case 8 : LossCount=14;break;
default: LossCount=1;// It is not the same as the 'case'
} // End of the 'switch' body
// GlobalVariableSet("Losscount"+Symbol(),LossCountCount);
GlobalVariableSet("Step"+Symbol(),LossCount);
// GlobalVariableSet("step"+Symbol(),step);
}//for (int cc = 0; cc <= tot -1; cc++)