Bago EA
Похожие материалы по тегам
Сообщите нам, если считаете, что материал размещён без разрешения.
Сообщить о материале
Обращение по товару «bago ea_5352742695041274852.mq5» отправится на рассмотрение. Укажите контакт для ответа и опишите причину.
О программе
Bago EA — это советник (Expert Advisor) для MetaTrader 5, реализующий трендовую торговую систему. В основе генерации сигналов лежат пересечения двух скользящих средних (EMA) и пересечение уровня RSI, при этом для фильтрации ложных сигналов используется Vegas Tunnel — полосовой фильтр на основе дополнительных скользящих средних.
Советник поддерживает фильтрацию по торговым сессиям (Лондон, Нью-Йорк, Токио), что позволяет работать только в выбранные часы. Также реализованы защитные механизмы: стоп-лосс, трейлинг-стоп с несколькими уровнями и частичное закрытие позиций поэтапно.
Входные параметры настраивают объём сделок, уровни стоп-лосса и трейлинга, периоды и типы скользящих средних, параметры RSI, ширину и безопасную зону туннеля, а также магическое число для идентификации позиций. Советник работает только при появлении нового бара.
Настройки программы
| Настройка | Описание |
|---|---|
| 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) | Ширина туннеля — Ширина полосы туннеля в пипсах |
| 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 Slow: ma_period (Inp_MA_Slow_ma_period) | Период медленной МА — Период медленной скользящей средней |
| MA's: horizontal shift (Inp_MA_ma_shift) | Сдвиг МА — Горизонтальный сдвиг скользящих средних |
| MA's: smoothing type (Inp_MA_ma_method) | Метод сглаживания МА — Метод сглаживания скользящих средних |
| MA's: type of price (Inp_MA_applied_price) | Тип цены для МА — Тип цены для расчёта скользящих средних |
| 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? После подтверждения оплаты файл сохранится в кабинете на этот email. Если аккаунта ещё нет, мы создадим его и пришлём ссылку для задания пароля. Если аккаунт уже есть, покупка добавится в него. Укажите адрес, к которому у вас есть доступ.
Чтобы оформить заказ, введите email и перейдите к оплате.