//+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- } //+------------------------------------------------------------------+ //---------------------- int ProfitHistoryOrdersCount(){ int ProfitHistoryOrdersCount = 0; for (int i = OrdersHistoryTotal()-1; i >=0; i--) if( OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() <= OP_SELL && OrderProfit() > 0 ) ProfitHistoryOrdersCount = (ProfitHistoryOrdersCount+1) % 6; return (ProfitHistoryOrdersCount); } //--------https://www.mql5.com/en/forum/136606 bool ProfitHistoryOrdersCount(int count){ int ProfitHistoryOrdersCount = 0; for (int i = OrdersHistoryTotal()-1; i >=0; i--) if( OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && OrderSymbol() == Symbol() && OrderMagicNumber() == magic && OrderType() <= OP_SELL ) { if (OrderProfit() > 0){ ProfitHistoryOrdersCount++;} if (ProfitHistoryOrdersCount == count) return(true); if (OrderProfit() <= 0){ return (false); } } //-------------------https://www.mql5.com/en/forum/94367 int OrdersTotalProfitable() { int count=0, total=OrdersHistoryTotal(); for(int i=total-1;i>=0;i--) if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY) && OrderSymbol()==_Symbol) { if(OrderProfit()<0.0) count++; else break; } return(count); printf("Total consecutive profitable orders: %d",OrdersTotalProfitable()); } //------------------------------------------------------------------------------------ void checkforlosses(int &losses, double &lot) // << Value could change outside this fuction { losses=0; for(int i=0; i=1;cnnt--) { if(OrdHistory>0 && OrderSymbol()==Symbol() && OrderMagicNumber()==magic){ if(OrderSelect(OrdHistory-cnnt,SELECT_BY_POS,MODE_HISTORY) && OrderProfit()>=0){LosCount=0;}//ProfCout++; else if(OrderSelect(OrdHistory-cnnt,SELECT_BY_POS,MODE_HISTORY) && OrderProfit()<0){LosCount++;} Comment(LosCount); } } } //------------------------------------------- //+-------https://www.forexfactory.com/showthread.php?t=230203 int Losses() { int Count = 0; for(int i=OrdersHistoryTotal()-1; i>=0; i--) { OrderSelect(i,SELECT_BY_POS,MODE_HISTORY); if(OrderProfit()>0) break; Count++; } return(Count); }