Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Expert Advisor | Altarius RSI Stohastic

The EA uses two iStochastic (Stochastic Oscillator) indicators and one iRSI (RSI, Relative Strength Index).

Author of the idea — cxa, author of the MQL5 code — barabashkakvn.  

Calculates the lot size based on the analysis of closed trades:

//+------------------------------------------------------------------+
//| Calculating optimal lot size                                  |
//+------------------------------------------------------------------+
double LotsOptimized()
  {
   double lot=Lots;
   int    losses=0;                  // number of losses deals without a break
//--- select lot size
   lot=NormalizeDouble(m_account.FreeMargin()*MaximumRisk/1000.0,2);
//--- calcuulate number of losses orders without a break
   if(DecreaseFactor>0)
     {
      //--- request trade history
      HistorySelect(TimeCurrent()-86400,TimeCurrent()+86400);
      //---
      uint     total=HistoryDealsTotal();
      //--- for all deals
      for(uint i=0;i<total;i++)
        {
         if(!m_deal.SelectByIndex(i))
           {
            Print("Error in history!");
            break;
           }
         if(m_deal.Symbol()!=Symbol() || m_deal.Entry()!=DEAL_ENTRY_OUT)
            continue;
         //---
         if(m_deal.Profit()>0)
            break;
         if(m_deal.Profit()<0)
            losses++;
        }
      if(losses>1)
         lot=NormalizeDouble(lot-lot*losses/DecreaseFactor,1);
     }
//--- return lot size
   if(lot<0.1)
      lot=0.1;
   return(lot);
  }

Results of Backtests on EURUSD and USDJPY:

MetaTrader Experts, Indicators, Scripts and Libraries 

MetaTrader Experts, Indicators, Scripts and Libraries 

MetaTrader Experts, Indicators, Scripts and Libraries 

MetaTrader Experts, Indicators, Scripts and Libraries 

17236

Best MetaTrader Indicators + Profitable Expert Advisors