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

ftmo robot v5.0 eurusd m15.mq4

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

2 to 1 strategy with signals.pineTradingView · 3 общих теговfresh algo signals & overlays v25_6334471093901859175.pineTradingView · 3 общих теговfresh algo v24 tradingview indicator_5918156155804195406.pineTradingView · 3 общих теговtrading criteria.mq4MQL4 / MetaTrader 4 · 3 общих теговthe predator.mq4MQL4 / MetaTrader 4 · 3 общих теговrisk reward ratio.mq4MQL4 / MetaTrader 4 · 3 общих тегов
Вы автор или правообладатель?

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

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

О программе

Данный советник предназначен для автоматической торговли на платформе MetaTrader 4 в паре EURUSD на таймфрейме M15. Он анализирует цены и технические индикаторы для формирования сигналов на открытие и закрытие позиций.

Советник использует набор технических индикаторов и фильтр по времени торговой сессии для определения точек входа. Позиции управляются со стоп-лоссом и тейк-профитом, с возможностью использования трейлинг-стопа.

Встроены механизмы защиты: ограничение по спреду и защита минимального эквити. Советник также поддерживает повторные попытки выполнения торговых операций при занятости торгового контекста.

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

НастройкаОписание
Stop_Loss Стоп-лосс в пипсах для управления рисками.
Take_Profit Тейк-профит в пипсах для фиксации прибыли.
Ind0Param0 Час начала торговой сессии (входной фильтр по времени).
Ind0Param1 Минута начала торговой сессии (входной фильтр по времени).
Ind0Param2 Час окончания торговой сессии (входной фильтр по времени).
Ind0Param3 Минута окончания торговой сессии (входной фильтр по времени).
Ind1Param0 Период индикатора Envelopes (скользящая средняя).
Ind1Param1 Отклонение индикатора Envelopes в процентах.
Ind2Param0 Период индикатора DeMarker.
Ind2Param1 Уровень индикатора DeMarker.
Ind3Param0 Быстрая EMA для индикатора MACD.
Ind3Param1 Медленная EMA для индикатора MACD.
Ind3Param2 Период SMA для сигнальной линии MACD.
Ind4Param0 Период первого индикатора RSI.
Ind4Param1 Уровень первого индикатора RSI.
Ind5Param0 Период второго индикатора RSI.
Ind5Param1 Уровень второго индикатора RSI.
Ind6Param0 Период индикатора Average True Range (ATR).
Ind6Param1 Уровень индикатора Average True Range (ATR) для фильтра закрытия позиции.
Получить полный код

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

#property version   "3.5"
#property strict

static input string _Properties_ = "------"; // --- Expert Properties ---
static input double Entry_Amount =     0.10; // Entry lots
       input int    Stop_Loss    =       25; // Stop Loss   (pips)
       input int    Take_Profit  =       90; // Take Profit (pips)

static input string ___0______   = "------"; // --- Entry Time ---
       input int    Ind0Param0   =        2; // From hour
       input int    Ind0Param1   =        0; // From minute
       input int    Ind0Param2   =       22; // Until hour
       input int    Ind0Param3   =        0; // Until minute

static input string ___1______   = "------"; // --- Envelopes ---
       input int    Ind1Param0   =       33; // Period
       input double Ind1Param1   =     0.06; // Deviation %

static input string ___2______   = "------"; // --- DeMarker ---
       input int    Ind2Param0   =       45; // Period
       input double Ind2Param1   =     0.45; // Level

static input string ___3______   = "------"; // --- MACD ---
       input int    Ind3Param0   =       25; // Fast EMA
       input int    Ind3Param1   =       35; // Slow EMA
       input int    Ind3Param2   =        9; // MACD SMA

static input string ___4______   = "------"; // --- RSI ---
       input int    Ind4Param0   =        5; // Period
       input int    Ind4Param1   =       43; // Level

static input string ___5______   = "------"; // --- RSI ---
       input int    Ind5Param0   =       20; // Period
       input int    Ind5Param1   =       30; // Level

static input string ___6______   = "------"; // --- Average True Range ---
       input int    Ind6Param0   =       30; // Period
       input double Ind6Param1   =   0.0015; // Level

static input string __Options___ = "------"; // --- Options ---
static input int    Magic_Number = 59611042; // Magic Number
static input int    Max_Spread   =        0; // Max spread protection (points)
static input int    Min_Equity   =        0; // Min equity protection (currency)

#define TRADE_RETRY_COUNT   4
#define TRADE_RETRY_WAIT  100
#define OP_FLAT            -1

int  sessionSundayOpen          =     0; // 00:00
int  sessionSundayClose         = 86400; // 24:00
int  sessionMondayThursdayOpen  =     0; // 00:00
int  sessionMondayThursdayClose = 86400; // 24:00
int  sessionFridayOpen          =     0; // 00:00
int  sessionFridayClose         = 86400; // 24:00
bool sessionIgnoreSunday        = true;
bool sessionCloseAtSessionClose = false;
bool sessionCloseAtFridayClose  = false;

const double sigma        = 0.000001;
const int    requiredBars = 48;

double posType       = OP_FLAT;
int    posTicket     = 0;
double posLots       = 0;
double posStopLoss   = 0;
double posTakeProfit = 0;

datetime barTime;
double   pip;
double   stopLevel;
bool     isTrailingStop          = false;
bool     setProtectionSeparately = false;

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

void OnDeinit(const int reason)
  {
  }

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

void OnBar(void)
  {
   UpdatePosition();

   if(posType != OP_FLAT && IsForceSessionClose())
     {
      ClosePosition();
      return;
     }

   if(IsOutOfSession())
      return;

   if(posType != OP_FLAT)
     {
      ManageClose();
      UpdatePosition();
     }

   if(posType != OP_FLAT && isTrailingStop)
     {
      double trailingStop = GetTrailingStopPrice();
      ManageTrailingStop(trailingStop);
      UpdatePosition();
     }

   int entrySignal = GetEntrySignal();

   if ((posType == OP_BUY  && entrySignal == OP_SELL) ||
       (posType == OP_SELL && entrySignal == OP_BUY ))
     {
      ClosePosition();

      int repeatCount = 80;
      int delay       = 50;
      for (int i = 0; i < repeatCount; i++)
      {
         UpdatePosition();
         if (posType == OP_FLAT) break;
         Sleep(delay);
      }
     }

   if(posType == OP_FLAT && entrySignal != OP_FLAT)
     {
      OpenPosition(entrySignal);
      UpdatePosition();
     }
  }

void UpdatePosition(void)
  {
   posType   = OP_FLAT;
   posTicket = 0;
   posLots   = 0;
   int total = OrdersTotal();

   for(int pos = total - 1; pos >= 0; pos -= 1)
     {
      if(OrderSelect(pos, SELECT_BY_POS) &&
         OrderSymbol()      == _Symbol   &&
         OrderMagicNumber() == Magic_Number)
        {
         posType       = OrderType();
         posLots       = OrderLots();
         posTicket     = OrderTicket();
         posStopLoss   = OrderStopLoss();
         posTakeProfit = OrderTakeProfit();
         break;
        }
     }
  }

int GetEntrySignal(void)
  {

   int fromTime0  = Ind0Param0 * 3600 + Ind0Param1 * 60;
   int untilTime0 = Ind0Param2 * 3600 + Ind0Param3 * 60;

   MqlDateTime mqlTime0;
   TimeToStruct(Time(0), mqlTime0);
   int barMinutes0 = mqlTime0.hour * 3600 + mqlTime0.min * 60;

   bool isOnTime0 = fromTime0 < untilTime0
      ? barMinutes0 >= fromTime0 && barMinutes0 <= untilTime0
      : barMinutes0 >= fromTime0 || barMinutes0 <= untilTime0;

   bool ind0long  = isOnTime0;
   bool ind0short = isOnTime0;

   double ind1upBand1 = iEnvelopes(NULL, 0, Ind1Param0, MODE_SMA, 0, PRICE_CLOSE, Ind1Param1, MODE_UPPER, 1);
   double ind1dnBand1 = iEnvelopes(NULL, 0, Ind1Param0, MODE_SMA, 0, PRICE_CLOSE, Ind1Param1, MODE_LOWER, 1);
   double ind1upBand2 = iEnvelopes(NULL, 0, Ind1Param0, MODE_SMA, 0, PRICE_CLOSE, Ind1Param1, MODE_UPPER, 2);
   double ind1dnBand2 = iEnvelopes(NULL, 0, Ind1Param0, MODE_SMA, 0, PRICE_CLOSE, Ind1Param1, MODE_LOWER, 2);
   bool   ind1long    = Open(0) > ind1dnBand1 + sigma && Open(1) < ind1dnBand2 - sigma;
   bool   ind1short   = Open(0) < ind1upBand1 - sigma && Open(1) > ind1upBand2 + sigma;

   double ind2val1  = iDeMarker(NULL, 0, Ind2Param0, 1);
   bool   ind2long  = ind2val1 > Ind2Param1 + sigma;
   bool   ind2short = ind2val1 < 1 - Ind2Param1 - sigma;

   double ind3val1  = iMACD(NULL, 0, Ind3Param0, Ind3Param1, Ind3Param2, PRICE_CLOSE, MODE_MAIN, 1);
   double ind3val2  = iMACD(NULL, 0, Ind3Param0, Ind3Param1, Ind3Param2, PRICE_CLOSE, MODE_MAIN, 2);
   bool   ind3long  = ind3val1 > ind3val2 + sigma;
   bool   ind3short = ind3val1 < ind3val2 - sigma;

   double ind4val1  = iRSI(NULL, 0, Ind4Param0, PRICE_CLOSE, 1);
   bool   ind4long  = ind4val1 > Ind4Param1 + sigma;
   bool   ind4short = ind4val1 < 100 - Ind4Param1 - sigma;

   double ind5val1  = iRSI(NULL, 0, Ind5Param0, PRICE_CLOSE, 1);
   double ind5val2  = iRSI(NULL, 0, Ind5Param0, PRICE_CLOSE, 2);
   double ind5val3  = iRSI(NULL, 0, Ind5Param0, PRICE_CLOSE, 3);
   bool   ind5long  = ind5val1 > ind5val2 + sigma && ind5val2 < ind5val3 - sigma;
   bool   ind5short = ind5val1 < ind5val2 - sigma && ind5val2 > ind5val3 + sigma;

   bool canOpenLong  = ind0long && ind1long && ind2long && ind3long && ind4long && ind5long;
   bool canOpenShort = ind0short && ind1short && ind2short && ind3short && ind4short && ind5short;

   return canOpenLong  && !canOpenShort ? OP_BUY
        : canOpenShort && !canOpenLong  ? OP_SELL
        : OP_FLAT;
  }

void ManageClose(void)
  {

   double ind6val1  = iATR(NULL, 0, Ind6Param0, 1);
   double ind6val2  = iATR(NULL, 0, Ind6Param0, 2);
   bool   ind6long  = ind6val1 > Ind6Param1 + sigma && ind6val2 < Ind6Param1 - sigma;
   bool   ind6short = ind6long;

   if((posType == OP_BUY  && ind6long) ||
        (posType == OP_SELL && ind6short) )
      ClosePosition();
  }

void OpenPosition(const int command)
  {
   if(!IsWithinMaxSpread()) return;

   for(int attempt = 0; attempt < TRADE_RETRY_COUNT; attempt++)
     {
      int    ticket     = 0;
      int    lastError  = 0;
      bool   modified   = false;
      string comment    = IntegerToString(Magic_Number);
      color  arrowColor = command == OP_BUY ? clrGreen : clrRed;

      if(IsTradeContextFree())
        {
         const double price      = command == OP_BUY ? Ask() : Bid();
         const double stopLoss   = GetStopLossPrice(command);
         const double takeProfit = GetTakeProfitPrice(command);

         if(setProtectionSeparately)
           {

            ticket = OrderSend(_Symbol, command, Entry_Amount, price,

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

Открыть по тарифу

Купите тариф с пакетом открытий или войдите, если тариф уже есть. Открытый файл останется в вашем кабинете навсегда.

Разовая покупка файла

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

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

Стоимость полного кода
1 217,40₽ ≈ $14.88