← К каталогу
Исходный код · ID 16

Bago EA

bago ea.mq5

Похожие материалы по тегам

precisionflowea.mq5MQL5 / MetaTrader 5 · 1 общих теговea robofibo source v.11.2.mq4MQL4 / MetaTrader 4 · 1 общих теговᴇɴᴛʀʏ.txtПлатформа не определена · 1 общих теговzonestrategy.mqhMQL5 / MetaTrader 5 · 1 общих теговxauusd_simple_strategy7.mq4MQL4 / MetaTrader 4 · 1 общих теговxauusd_grok_presisi_scalper_v1.4 - anti detach.mq5MQL5 / MetaTrader 5 · 1 общих тегов
Вы автор или правообладатель?

Сообщите нам, если считаете, что материал размещён без разрешения.

Краткий обзор

О программе

Bago EA — советник для платформы MetaTrader 5, реализующий систему торговли Bago. Советник работает на основе пересечения экспоненциальных скользящих средних, индикатора RSI и канала Vegas Tunnel. Он определяет направление тренда и фильтрует сигналы с использованием зоны канала и уровней Фибоначчи. Торговля ведётся в определённые сессии (Лондон, Нью-Йорк, Токио) с управлением позицией через стоп-лосс, трейлинг-стоп и частичное закрытие объёма.

Настройки программы

НастройкаОписание
Lots (InpLots) Лоты — Объём позиции в лотах для открытия сделки
Stop Loss, in pips (1.00045-1.00055=1 pips) (InpStopLoss) Стоп-лосс — Расстояние стоп-лосса в пунктах от цены входа
Stop Loss to Fibo, in pips (1.00045-1.00055=1 pips) (InpStopLossToFibo) Стоп-лосс до Фибо — Дополнительный отступ стоп-лосса до уровня Фибоначчи в пунктах
Trailing Stop (min distance from price to Stop Loss, in pips (InpTrailingStop) Трейлинг-стоп — Минимальное расстояние от текущей цены до уровня стоп-лосса при трейлинге в пунктах
Trailing Step 1, in pips (1.00045-1.00055=1 pips) (InpTrailingStep1) Шаг трейлинга 1 — Первый уровень отступа для перемещения стоп-лосса при движении цены в пунктах
Lots partially closes 1 (InpLotsClosePartial1) Частичное закрытие 1 — Объём лотов, закрываемый частично при достижении первого уровня трейлинга
Trailing Step 2, in pips (1.00045-1.00055=1 pips) (InpTrailingStep2) Шаг трейлинга 2 — Второй уровень отступа для перемещения стоп-лосса в пунктах
Lots partially closes 2 (InpLotsClosePartial2) Частичное закрытие 2 — Объём лотов, закрываемый частично при достижении второго уровня трейлинга
Trailing Step 3, in pips (1.00045-1.00055=1 pips) (InpTrailingStep3) Шаг трейлинга 3 — Третий уровень отступа для перемещения стоп-лосса в пунктах
Tunnel BandWidth, in pips (1.00045-1.00055=1 pips) (InpTunnelBandWidth) Ширина туннеля — Ширина полосы канала Vegas Tunnel в пунктах
Tunnel Safe Zone, in pips (1.00045-1.00055=1 pips) (InpTunnelSafeZone) Безопасная зона туннеля — Допустимая зона внутри канала перед входом в сделку в пунктах
London open (LondonOpen) Лондонская сессия — Включает или отключает торговлю в лондонской сессии
NewYork open (NewYorkOpen) Нью-Йоркская сессия — Включает или отключает торговлю в нью-йоркской сессии
Tokyo open (TokyoOpen) Токийская сессия — Включает или отключает торговлю в токийской сессии
MA Fast: ma_period (Inp_MA_Fast_ma_period) Период быстрой MA — Период быстрой скользящей средней
MA Slow: ma_period (Inp_MA_Slow_ma_period) Период медленной MA — Период медленной скользящей средней
MA's: horizontal shift (Inp_MA_ma_shift) Сдвиг MA — Горизонтальный сдвиг скользящих средних
MA's: smoothing type (Inp_MA_ma_method) Метод сглаживания MA — Тип сглаживания для скользящих средних
MA's: type of price (Inp_MA_applied_price) Тип цены для MA — Тип цены, используемый для расчёта скользящих средних
RSI: averaging period (Inp_RSI_ma_period) Период RSI — Период усреднения индикатора RSI
RSI: type of price (Inp_RSI_applied_price) Тип цены для RSI — Тип цены, используемый для расчёта RSI
magic number (m_magic) Магический номер — Уникальный номер для идентификации ордеров советника
Получить полный код

Поиск по коду файла

#property version   "1.000"

#include <Trade\PositionInfo.mqh>
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>  
#include <Trade\AccountInfo.mqh>
CPositionInfo  m_position;                   // trade position object
CTrade         m_trade;                      // trading object
CSymbolInfo    m_symbol;                     // symbol info object
CAccountInfo   m_account;                    // account info wrapper
/*
Bago system can be categorized as a trend following system based on 
the cross of ema 5 and ema 12. When used properly on hourly chart it 
can capture daily swings of 100+ pips.

The use of small number emas gives Bago system the sensitivity to 
generate early signals following 10-20 minutes scale waves, but also 
produces a great deal of false signals that can quickly drain a trader
's account. So filters are extremely important for Bago system.

While Bago system is largely a discretionary system, the integration of 
two excellent filters may make it possible to use a computer program
generate signals with great high successful rate. This program is 
writtern to investigate this possiblity.

The mechanism to generate a raw Bago signal is simple: ema 5 crosses 
ema 12 in the same direction as RSI 21 crosses 50 level. To abstract 
real signals, we need to pay attention to context: where the price are,
and when the crosses happens.

The greatest meaning of integrating Vegas tunnel into Bago system is, 
the tunnel as well as its fibo lines changes the original plain 2-d
space into a twisted 2-d space. The twisted price trends now have the
coordinates. With this coordinates system we may see the entry and exit
with higher accuracy.

So, this program will first construct the simple rules upon which the 
the raw signals are generated, then will add rules to filter those 
signals. Those new rules are quantified as parameters so they can be 
easily changed and optimized based on the output results.

Enough talking, now come to business.
*/

input double               InpLots                    = 3.0;               // Lots
input ushort               InpStopLoss                = 30;                // Stop Loss, in pips (1.00045-1.00055=1 pips)
input ushort               InpStopLossToFibo          = 20;                // Stop Loss to Fibo, in pips (1.00045-1.00055=1 pips)
input ushort               InpTrailingStop            = 30;                // Trailing Stop (min distance from price to Stop Loss, in pips
input ushort               InpTrailingStep1           = 55;                // Trailing Step 1, in pips (1.00045-1.00055=1 pips)
input double               InpLotsClosePartial1       = 1.0;               // Lots partially closes 1
input ushort               InpTrailingStep2           = 89;                // Trailing Step 2, in pips (1.00045-1.00055=1 pips)
input double               InpLotsClosePartial2       = 1.0;               // Lots partially closes 2
input ushort               InpTrailingStep3           = 144;               // Trailing Step 3, in pips (1.00045-1.00055=1 pips)
int                        CrossEffectiveTime         = 2;                 // Cross effective time
input ushort               InpTunnelBandWidth         = 5;                 // Tunnel BandWidth, in pips (1.00045-1.00055=1 pips)
input ushort               InpTunnelSafeZone          = 120;               // Tunnel Safe Zone, in pips (1.00045-1.00055=1 pips)
input bool                 LondonOpen                 = true;              // London open
input bool                 NewYorkOpen                = true;              // NewYork open
input bool                 TokyoOpen                  = false;             // Tokyo open

input int                  Inp_MA_Fast_ma_period      = 5;                 // MA Fast: ma_period
input int                  Inp_MA_Slow_ma_period      = 12;                // MA Slow: ma_period
input int                  Inp_MA_ma_shift            = 0;                 // MA's: horizontal shift
input ENUM_MA_METHOD       Inp_MA_ma_method           = MODE_EMA;          // MA's: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_applied_price       = PRICE_CLOSE;       // MA's: type of price

input int                  Inp_RSI_ma_period          = 21;                // RSI: averaging period 
input ENUM_APPLIED_PRICE   Inp_RSI_applied_price      = PRICE_CLOSE;       // RSI: type of price

input ulong    m_magic=373062807;            // magic number

ulong  m_slippage=10;                        // slippage
double ExtStopLoss;
double ExtStopLossToFibo;
double ExtTrailingStop;
double ExtTrailingStep1;
double ExtTrailingStep2;
double ExtTrailingStep3;
double ExtTunnelBandWidth;
double ExtTunnelSafeZone;

int    handle_iMA_Fast;                      // variable for storing the handle of the iMA indicator
int    handle_iMA_Slow;                      // variable for storing the handle of the iMA indicator
int    handle_iMA_Vegas_Fast;                // variable for storing the handle of the iMA indicator
int    handle_iMA_Vegas_Slow;                // variable for storing the handle of the iMA indicator
int    handle_iRSI;                          // variable for storing the handle of the iRSI indicator
double m_adjusted_point;                     // point value adjusted for 3 or 5 points

bool   EMACrossedUp;
bool   EMACrossedDown;
bool   RSICrossedUp;
bool   RSICrossedDown;
bool   TunnelCrossedUp;
bool   TunnelCrossedDown;

int    EMACrossedUpTimer;
int    RSICrossedUpTimer;
int    EMACrossedDownTimer;
int    RSICrossedDownTimer;

int OnInit()
  {
      // код доступен только после оплаты
   }

void OnDeinit(const int reason)
  {

   EMACrossedUp         = false;
   RSICrossedUp         = false;
   TunnelCrossedUp      = false;
   EMACrossedDown       = false;
   RSICrossedDown       = false;
   TunnelCrossedDown    = false;

   EMACrossedUpTimer    = 0;
   RSICrossedUpTimer    = 0;
   EMACrossedDownTimer  = 0;
   RSICrossedDownTimer  = 0;
  }

void OnTick()
  {
      // код доступен только после оплаты
   }

   static datetime PrevBars=0;
   datetime time_0=iTime(m_symbol.Name(),Period(),0);
   if(time_0==PrevBars)
      return;
   PrevBars=time_0;
   if(!RefreshRates())
     {
      PrevBars=0;
      return;
     }

   double ma_fast[],ma_slow[],rsi[],ma_vegas_fast[],ma_vegas_slow[],open[],close[];
   ArraySetAsSeries(ma_fast,true);
   ArraySetAsSeries(ma_slow,true);
   ArraySetAsSeries(rsi,true);
   ArraySetAsSeries(ma_vegas_fast,true);
   ArraySetAsSeries(ma_vegas_slow,true);
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(close,true);

   int buffer=0,start_pos=0,count=3;
   if(!iGetArray(handle_iMA_Fast,buffer,start_pos,count,ma_fast) || 
      !iGetArray(handle_iMA_Slow,buffer,start_pos,count,ma_slow) || 
      !iGetArray(handle_iRSI,buffer,start_pos,count,rsi) || 
      !iGetArray(handle_iMA_Vegas_Fast,buffer,start_pos,count,ma_vegas_fast) || 
      !iGetArray(handle_iMA_Vegas_Slow,buffer,start_pos,count,ma_vegas_slow) || 
      CopyOpen(m_symbol.Name(),Period(),start_pos,count,open)!=count || 
      CopyClose(m_symbol.Name(),Period(),start_pos,count,close)!=count)
     {
      PrevBars=0;
      return;
     }

   if((rsi[1]>50) && (rsi[2]<50) && (RSICrossedUp==false))
     {
      RSICrossedUp  =true;
      RSICrossedDown=false;
     }
   if(RSICrossedUp==true)
      RSICrossedUpTimer++;  // Record the number of bars the cross has happened
   else
      RSICrossedUpTimer=0;  // Reset the timer once the cross is reversed
   if(RSICrossedUpTimer>=CrossEffectiveTime)
      RSICrossedUp=false; // Reset state register when crossed 3 bars ago

   if((rsi[1]<50) && (rsi[2]>50) && (RSICrossedDown==false))
     {
      RSICrossedUp  =false;
      RSICrossedDown=true;
     }
   if(RSICrossedDown==true)
      RSICrossedDownTimer++;  // Record the number of bars the cross has happened
   else
      RSICrossedDownTimer=0;  // Reset the timer once the cross is reversed
   if(RSICrossedDownTimer>=CrossEffectiveTime)
      RSICrossedDown=false; // Reset register when crossed 3 bars ago

   if((ma_fast[1]>ma_slow[1]) && 
      (ma_fast[2]<ma_slow[2]) && 
      (EMACrossedUp==false))
     {
      EMACrossedUp  =true;
      EMACrossedDown=false;
     }
   if(EMACrossedUp==true)
      EMACrossedUpTimer++;  // Record the number of bars the cross has happened
   else
      EMACrossedUpTimer=0;  // Reset the timer once the cross is reversed
   if(EMACrossedUpTimer>=CrossEffectiveTime)
      EMACrossedUp=false; // Reset register when crossed 3 bars ago

   if((ma_fast[1]<ma_slow[1]) && 
      (ma_fast[2]>ma_slow[2]) && 
      (EMACrossedDown==false))
     {
      EMACrossedUp  =false;
      EMACrossedDown=true;
     }
   if(EMACrossedDown==true)
      EMACrossedDownTimer++;  // Record the number of bars the cross has happened
   else
      EMACrossedDownTimer=0;  // Reset the timer once the cross is reversed
   if(EMACrossedDownTimer>=CrossEffectiveTime)
      EMACrossedDown=false; // Reset register when crossed 3 bars ago
   if((close[1]>ma_vegas_fast[0] && close[1]>ma_vegas_slow[0]) && 
      (close[2]<ma_vegas_fast[0] || close[2]<ma_vegas_slow[0]))
     {
      TunnelCrossedUp  =true;
      TunnelCrossedDown=false;
     }
   if((close[1]<ma_vegas_fast[0] && close[1]<ma_vegas_slow[0]) && 
      (close[2]>ma_vegas_fast[0] || close[2]>ma_vegas_slow[0]))
     {
      TunnelCrossedUp  =false;
      TunnelCrossedDown=true;
     }

   MqlDateTime STime0;
   TimeToStruct(time_0,STime0);
   if(!(
      (LondonOpen==true && STime0.hour>=7 && STime0.hour<=16) || 
      (NewYorkOpen==true && STime0.hour>=12 && STime0.hour<=21) || 
      (TokyoOpen==true && STime0.hour>=0 && STime0.hour<=8) || 
      (STime0.hour>=23)
      ))
     {

      return;
     }
   else
     {

      if(!RefreshRates())
        {
         PrevBars=0;
         return;
        }
      double freeze_level=m_symbol.FreezeLevel()*m_symbol.Point();
      if(freeze_level==0.0)
         freeze_level=(m_symbol.Ask()-m_symbol.Bid())*3.0;
      freeze_level*=1.1;

      double stop_level=m_symbol.StopsLevel()*m_symbol.Point();
      if(stop_level==0.0)
         stop_level=(m_symbol.Ask()-m_symbol.Bid())*3.0;
      stop_level*=1.1;

      if(freeze_level<=0.0 || stop_level<=0.0)
        {
         PrevBars=0;
         return;
        }

      if((EMACrossedUp==true) && (RSICrossedUp==true) && // Raw long signal generating rules

         ((close[1]>=ma_vegas_slow[0]+ExtTunnelBandWidth && // Above whipsaw zone
         close[1]<=ma_vegas_slow[0]+ExtTunnelSafeZone && // Below high fibo line
         open[1]<close[1]) || // Price push up from a bull bar
         (close[1]<=ma_vegas_slow[0]-ExtTunnelBandWidth) // Testing from below the tunnel
         ))
        {
         double price=m_symbol.Ask();
         double sl=(InpStopLoss==0)?0.0:price-ExtStopLoss;
         if(((sl!=0 && ExtStopLoss>=stop_level) || sl==0.0))
           {
            OpenBuy(sl,0.0);
            return;
           }
         return;
        }

      if((EMACrossedDown==true) && (RSICrossedDown==true) && // Raw short signal generating rules

         ((close[1]<=ma_vegas_slow[0]-ExtTunnelBandWidth && // Below whipsaw zone
         close[1]>=ma_vegas_slow[0]-ExtTunnelSafeZone && // Above high fibo line
         open[1]>close[1]) || // Price down from a bear bar
         (close[1]>=ma_vegas_slow[0]+ExtTunnelBandWidth) // Testing from above the tunnel
         ))
        {
         double price=m_symbol.Bid();
         double sl=(InpStopLoss==0)?0.0:price+ExtStopLoss;
         if(((sl!=0 && ExtStopLoss>=stop_level) || sl==0.0))
           {
            OpenSell(sl,0.0);
            return;
           }
         return;
        }
     }

   for(int i=PositionsTotal()-1;i>=0;i--) // returns the number of open positions
      if(m_position.SelectByIndex(i))
         if(m_position.Symbol()==m_symbol.Name() && m_position.Magic()==m_magic)
           {
            if(m_position.PositionType()==POSITION_TYPE_BUY)
              {

               if((EMACrossedDown==true) || (RSICrossedDown==true))
                 {
                  m_trade.PositionClose(m_position.Ticket());
                  continue;
                 }

               if(TunnelCrossedUp==true)
                 {
                  if(m_symbol.Bid()>=(ma_vegas_slow[0]+ExtTrailingStep3))
                    {
                     if(m_position.StopLoss()<m_symbol.Bid()-ExtTrailingStop && 
                        !CompareDoubles(m_position.StopLoss(),m_symbol.Bid()-ExtTrailingStop,m_symbol.Digits()))
                        if(!m_trade.PositionModify(m_position.Ticket(),
                           m_symbol.NormalizePrice(m_symbol.Bid()-ExtTrailingStop),
                           m_position.TakeProfit()))
                          {

                           m_position.SelectByIndex(i);
                           PrintResultModify(m_trade,m_symbol,m_position);
                          }
                     continue;
                    }

                  else if(m_symbol.Bid()>=(ma_vegas_slow[0]+ExtTrailingStep2))
                    {
                     if(m_position.Volume()>InpLotsClosePartial2 && m_position.PriceOpen()<ma_vegas_slow[0]+ExtTrailingStep2)
                        m_trade.PositionClosePartial(m_position.Ticket(),InpLotsClosePartial2);
                     if(m_position.StopLoss()<m_symbol.Bid()-ExtTrailingStop && 
                        !CompareDoubles(m_position.StopLoss(),m_symbol.Bid()-ExtTrailingStop,m_symbol.Digits()))
                        if(!m_trade.PositionModify(m_position.Ticket(),
                           m_symbol.NormalizePrice(m_symbol.Bid()-ExtTrailingStop),
                           m_position.TakeProfit()))

Показано первые 50% кода (символов: 25588)

Что вы получите после оплаты

На этой странице откроется полный исходный код файла вместо ознакомительного фрагмента.

Чтобы оформить заказ, введите email и перейдите к оплате.

Стоимость полного кода
2 559₽