MySystem – EA MetaTrader 5

The author of the idea: Collector

MQL5 code author: barabashkakvn

The EA only operates when a new bar appears. A trading signal from the iBullsPower (Bulls Power) and iBearsPower (Bears Power) indicators is considered only if the market has no positions opened by the EA (the search is performed by the current symbol and the current unique EA identifier – magic number).

Both indicators feature only one setting – Bulls and Bears: averaging period. Trading signal forming algorithm: data from two bars – Bar current and Bar current+1 – are taken in both indicators and the values are divided by 2

   double prev = ((bears[1]+bulls[1])/2.0);
   double curr = ((bears[0]+bulls[0])/2.0);

If the average value on the previous bar is less than on the current one, open BUY:

      if(prev<curr && curr<0)
        {
         //ClosePositions(POSITION_TYPE_SELL);
         double sl=(InpStopLoss==0)?0.0:m_symbol.Ask()-ExtStopLoss;
         if(sl>=m_symbol.Bid()) // incident: the position isn't opened yet, and has to be already closed
           {
            PrevBars=0;
            return;
           }
         double tp=(InpTakeProfit==0)?0.0:m_symbol.Ask()+ExtTakeProfit;
         OpenBuy(sl,tp);
         return;
        }

If the average value on the previous bar exceeds the current one, open SELL:

Alternative:  Background_Candles_Smoothed_Step_HTF - indicator MetaTrader 5
      if(prev>curr && curr>0)
        {
         //ClosePositions(POSITION_TYPE_BUY);
         double sl=(InpStopLoss==0)?0.0:m_symbol.Bid()+ExtStopLoss;
         if(sl<=m_symbol.Ask()) // incident: the position isn't opened yet, and has to be already closed
           {
            PrevBars=0;
            return;
           }
         double tp=(InpTakeProfit==0)?0.0:m_symbol.Bid()-ExtTakeProfit;
         OpenSell(sl,tp);
         return;
        }

EURUSD, M15:



https://www.mql5.com/ru/code/22016

📈 ROBOTFX MetaTrader Expert Advisors and Indicators to maximize profits and minimize the risks