Stop trading until end of month if 4 losses in a row

 
Trying to figure this out has got my brain in a bundle, lol, so my thinking would be to pull the trade information for the last 4 trades made and IF all of them resulted in loss, then SLEEP until the month = (currentmonth) + 1, would this work and anyone want to possibly offer a good structured code instead of my sloppiness? =D
 

Here is the code so far, I'm trying to find a good way to calculate the time to sleep until end of month though:

 

int LosCount=0; // ,ProfCout=0;
   int OrdHistory=OrdersHistoryTotal();
   if(OrdHistory>0 && OrderSymbol()==Symbol())
   { for(int cntl=MaxLosses;cntl>=1;cntl--)
      {
         if(OrderSelect(OrdHistory-cntl,SELECT_BY_POS,MODE_HISTORY) && OrderProfit()>=0)LosCount=0;//ProfCout++;
         if(OrderSelect(OrdHistory-cntl,SELECT_BY_POS,MODE_HISTORY) && OrderProfit()<0)LosCount++;
      }
   }
   //Comment(LosCount); // check counter in live

if(LosCount > MaxLosses) {
Sleep();
}
 
   if(OrdHistory>0 && OrderSymbol()==Symbol())

You have not selected an order yet so OrderSymbol() could be anything.

I your loop, you are assuming that the history is in a certain order. Also you are assuming that they are of the correct symbol

 
remix919: I'm trying to find a good way to calculate the time to sleep until end of month though:
Don't sleep, just ignore ticks
void OnTick(){
   static int ignoreMonth = 0;
   if(Month() == ignoreMonth) return;
   ignoreMonth = 0; // Clear for next year.
   :
   if(condition){ ignoreMonth = Month(); return; } // Stop trading
 
Slight issue with that code, or perhaps rather my original code. The problem is once next month hits, then it re-calculates how many trades lost in a row, but it still shows the same 4 from last month so it just doesn't trade at all =\ any ideas?
 
Fix your code. If the trades are not the current month/current year, why are you counting them?