Задать алгоритм вручную и автоматизировать эксперта.

 

Для будущего моего Эксперта - хочу разложить по полочкам его внутренности, что бы можно было понимать как им пользоваться. 

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

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Какие функции я хочу заложить в него!

1. Закрытие Прибыли общей.

2. Закрытие Прибыли на отдельном Графике.

3. Закрытие Прибыли по отдельности от BUY и отдельно по SELL.

4. Задать команду от Вертикальной линии.

5. Задать команду от Горизонтальной или Трендовой линии.(как от имени линии -а также от цвета линии)

6. Получение Сигнала от Индикатора и выбор команд.

7. Трал Горизонтальных линии.

8. Фильтр -который будет разделять Все функции на UP и DOWN с помощью Горизонтальной линии( Выше UP работают половина функции и  DOWN другая половина)

9. Отскок Горизонтальных линии от срабатывания Сигнала на заданное расстояние.  

\пока всё\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 

 

1. Функция - предназначена для выбора команды от Сигнала.

//+------------------------------------------------------------------+
//| ENUM_TRADE_COMMAND                                               |
//+------------------------------------------------------------------+
enum ENUM_TRADE_COMMAND
  {   
   close_open_b=24,   // Close Sell + Open Buy
   close_open_s=25,   // Close Buy + Open Sell
  };
input ENUM_TRADE_COMMAND InpLongOpened_1Command  = close_open_b; // Buy command:
input ENUM_TRADE_COMMAND InpShortOpened_1Command = close_open_s; // Sell command:
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
bool  CSampleExpert::InpTradeCommand(int i)
  {
   bool res=false;
//---  второй пример
   switch(i)
     {
      case Turn_Off:// TURN OFF
         ExtTurnOff=true;
         break;
      case tpl:// '.tpl' All
         ExttplAll=true;
         DeleteChart();
         break;
      case Close_AllExt:// CloseAll + ExpertRemoves
         ExtAllCloseAll=true;
         NotifyAllCloseAll("");
         ExpertRemove();
         DeleteChart();
         PlaySound("expert.wav");
         break;
      case Close_All_All:// CloseAll
         ExtAllCloseAll=true;
         NotifyAllCloseAll("");
         break;
      case  close_tpl_b:// Close Sell + Open Buy + '.tpl'
         ExtNeedCloseSell=true;
         NotifyCrossingClosSell("");
         ExtNeedOpenBuy=true;
         NotifyCrossingBuy("");
         ExpertRemove();
         DeleteChart_1();
         break;
      case  close_tpl_s:// Close Buy + Open Sell + '.tpl'
         ExtNeedCloseBuy=true;
         NotifyCrossingClosBuy("");
         ExtNeedOpenSell=true;
         NotifyCrossingSell("");
         ExpertRemove();
         DeleteChart_1();
         break;
      case close_all_tpl:// Close Buy's Sell's + '.tpl'
         ExtNeedCloseAll=true;
         NotifyLongShortClos("");
         ExpertRemove();
         DeleteChart_1();
         break;
      case  UpName:// Line Open UpName
         ExtUpName=true;
         Obj_BUYOpen();
         break;
      case  DownName:// Line Open DownName
         ExtDownName=true;
         Obj_SELLOpen();
         break;
      case  UpName_s:// Line Open UpName + Open Sell
         ExtUpName=true;
         Obj_BUYOpen();
         ExtNeedOpenSell=true;
         NotifyCrossingSell("");
         break;
      case  UpName_b:// Line Open UpName + Open Buy
         ExtUpName=true;
         Obj_BUYOpen();
         ExtNeedOpenBuy=true;
         NotifyCrossingBuy("");
         break;
      case  DownName_b:// Line Open DownName + Open Buy
         ExtDownName=true;
         Obj_SELLOpen();
         ExtNeedOpenBuy=true;
         NotifyCrossingBuy("");
         break;
      case  DownName_s:// Line Open DownName + Open Sell
         ExtDownName=true;
         Obj_SELLOpen();
         ExtNeedOpenSell=true;
         NotifyCrossingSell("");
         break;
      case  ClUpName:// Line Close UpName
         ClExtUpName=true;
         Obj_BUYClos();
         break;
      case  ClDownName:// Line Close DownName
         ClExtDownName=true;
         Obj_SELLClos();
         break;
      case  ClUpName_s:// Line Close UpName + Open Sell
         ClExtUpName=true;
         Obj_BUYClos();
         ExtNeedOpenSell=true;
         NotifyCrossingSell("");
         break;
      case  ClUpName_b:// Line Close UpName + Open Buy
         ClExtUpName=true;
         Obj_BUYClos();
         ExtNeedOpenBuy=true;
         NotifyCrossingBuy("");
         break;
      case  ClDownName_b:// Line Close DownName + Open Buy
         ClExtDownName=true;
         Obj_SELLClos();
         ExtNeedOpenBuy=true;
         NotifyCrossingBuy("");
         break;
      case  ClDownName_s:// Line Close DownName + Open Sell
         ClExtDownName=true;
         Obj_SELLClos();
         ExtNeedOpenSell=true;
         NotifyCrossingSell("");
         break;
      case  close_buys:// Close All Buy's
         ExtNeedCloseBuy=true;
         NotifyCrossingClosBuy("");
         break;
      case  close_sells:// Close All Sell's
         ExtNeedCloseSell=true;
         NotifyCrossingClosSell("");
         break;
      case close_all:// Close All Buy's and Sell's
         ExtNeedCloseAll=true;
         NotifyLongShortClos("");
         break;
      case open_buy:// Open  Buy
         ExtNeedOpenBuy=true;
         NotifyCrossingBuy("");
         break;
      case open_sell:// Open  Sell
         ExtNeedOpenSell=true;
         NotifyCrossingSell("");
         break;
      case  close_open_b:// Close Sell + Open Buy
         ExtNeedCloseSell=true;
         NotifyCrossingClosSell("");
         ExtNeedOpenBuy=true;
         NotifyCrossingBuy("");
         break;
      case  close_open_s:// Close Buy + Open Sell
         ExtNeedCloseBuy=true;
         NotifyCrossingClosBuy("");
         ExtNeedOpenSell=true;
         NotifyCrossingSell("");
         break;
      case  open_buy_sell:// Open  Buy and Sell
         ExtNeedOpenBuy=true;
         NotifyCrossingBuy("");
         ExtNeedOpenSell=true;
         NotifyCrossingSell("");
         break;
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+

например от Индикатора 

//+------------------------------------------------------------------+
//| Check for long position opening                                  |
//+------------------------------------------------------------------+
bool CSampleExpert::LongOpened_1(void)
  {
   bool res=false;
//--- check for long position (BUY) possibility
   if(m_macd_current_1<m_signal_current_1)
     {
      InpTradeCommand(InpLongOpened_1Command);
      PlaySound("ok.wav");
      //--- in any case we must exit from expert
      res=true;
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
//| Check for short position opening                                 |
//+------------------------------------------------------------------+
bool CSampleExpert::ShortOpened_1(void)
  {
   bool res=false;
//--- check for short position (SELL) possibility
   if(m_macd_current_1>m_signal_current_1)
     {
      InpTradeCommand(InpShortOpened_1Command);
      PlaySound("ok.wav");
      //--- in any case we must exit from expert
      res=true;
     }
//--- result
   return(res);
  }
//+------------------------------------------------------------------+
 

Такой Эксперт уже есть https://www.mql5.com/ru/code/30444

В Этот будет добавлено от четырёх линии Горизонтальных или Трендовых от их цвета, будет срабатывать команда из выбора команд.

Ещё от каждого выполнения каких либо действий Эксперта - можно настроить ( SendNotification https://www.mql5.com/ru/docs/network/sendnotification )и (SendMail https://www.mql5.com/ru/docs/network/sendmail)

   if(EnableNotificationsBuy)
      SendNotification(msg);
   if(EnableEmailsBuy)
      SendMail(EAName+" EventBuy",msg);
   Print(msg);


   

Semaphore Line
Semaphore Line
  • www.mql5.com
Эксперт работает с использованием семафорных индикаторов а так же, от Горизонтальных и Трендовых линии
 

Вроде закончил склеивать Эксперта - Осталось проверить в рынке его работоспособность. 

Так выглядит настраиваемая часть кода.

//+------------------------------------------------------------------+
//|                                  Algorithm manually automate.mq5 |
//|                           Copyright © 2021, Aleksandr Klapatyuk. |
//|                            https://www.mql5.com/ru/users/sanalex |
//+------------------------------------------------------------------+
#property copyright   "Copyright © 2021, Aleksandr Klapatyuk"
#property link        "https://www.mql5.com/ru/users/sanalex"
#define   EAName      "Algorithm manually automate"
#define   EAVersion   "1.000"
#property description "Copyright 2021, Strx"
#property description "https://www.mql5.com/en/users/strx"
#property description "Copyright © 2021, Vladimir Karputov"
#property description "http://wmua.ru/slesar/"
#property description "Klymenko Roman (needtome@icloud.com)"
#property description "https://www.mql5.com/ru/users/needtome"
#property description "Copyright © 2021, SEM "
#property description "https://www.mql5.com/ru/users/seliveru"
#property version     EAVersion
//---
#define MACD_MAGIC 7775613
//---
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\PositionInfo.mqh>
#include <Trade\AccountInfo.mqh>
#include <Arrays\ArrayString.mqh>
#include <ChartObjects\ChartObject.mqh>
#include <ChartObjects\ChartObjectsLines.mqh>
//+------------------------------------------------------------------+
//| ENUM_PROFIT_COMMAND                                              |
//+------------------------------------------------------------------+
enum ENUM_MODE
  {
   mode_All=0,        // ВКЛ.
   mode_Ind=1,        // ВЫКЛ. Фильтр
  };
//+------------------------------------------------------------------+
//| ENUM_PROFIT_COMMAND                                              |
//+------------------------------------------------------------------+
enum ENUM_P
  {
   tpl_b=0,           // Close
   tpl_s=1,           // Close + Open + '.tpl'
  };
//+------------------------------------------------------------------+
//| ENUM_FILTER_COMMAND                                              |
//+------------------------------------------------------------------+
enum ENUM_FILTR_COMMAND
  {
   Filter_Off=0,      // OFF
   Filter_Stop=1,     // Filter Line Up:Down
   Filter_All=2,      // Filter Line Up:Down:Middle
  };
//+------------------------------------------------------------------+
//| ENUM_TRADE_COMMAND                                               |
//+------------------------------------------------------------------+
enum ENUM_TRADE_COMMAND
  {
   Turn_Off=0,        // TURN OFF
   tpl=1,             // '.tpl' All
   Close_AllExt=2,    // CloseAll + ExpertRemoves
   Close_All_All=3,   // CloseAll
   close_tpl_b=4,     // Close Sell + Open Buy + '.tpl'
   close_tpl_s=5,     // Close Buy + Open Sell + '.tpl'
   close_all_tpl=6,   // Close Buy's Sell's + '.tpl'
   UpName=7,          // Line Open UpName
   DownName=8,        // Line Open DownName
   UpName_s=9,        // Line Open UpName + Open Sell
   UpName_b=10,       // Line Open UpName + Open Buy
   DownName_b=11,     // Line Open DownName + Open Buy
   DownName_s=12,     // Line Open DownName + Open Sell
   ClUpName=13,       // Line Close UpName
   ClDownName=14,     // Line Close DownName
   ClUpName_s=15,     // Line Close UpName + Open Sell
   ClUpName_b=16,     // Line Close UpName + Open Buy
   ClDownName_b=17,   // Line Close DownName + Open Buy
   ClDownName_s=18,   // Line Close DownName + Open Sell
   close_buys=19,     // Close All Buy's
   close_sells=20,    // Close All Sell's
   close_all=21,      // Close All Buy's and Sell's
   open_buy=22,       // Open  Buy
   open_sell=23,      // Open  Sell
   close_open_b=24,   // Close Sell + Open Buy
   close_open_s=25,   // Close Buy + Open Sell
   open_buy_sell=26,  // Open  Buy and Sell
  };
//+------------------------------------------------------------------+
sinput group "----------------- Balans Parameters --------------------"
sinput ENUM_TIMEFRAMES    TimeFrame                  = PERIOD_CURRENT;   // Change TimeFrame - Current = dont changed
sinput string             Template                   = "ADX";            // Имя шаблона(without '.tpl')
sinput double             TargetProfit               = 1000000;          // Баланс + Прибыль(прибавить к балансу)
sinput double             TargetLoss                 = 0;                // Баланс - Убыток(отнять от баланса)
sinput bool               AllCloseAllNotifications   = false;            // AllCloseAllNotifications
sinput bool               AllCloseAllEmails          = false;            // AllCloseAllEmails
sinput group "----------------- Balans Parameters 1 ------------------"
sinput double             TargetProfit_1             = 1000000;          // Общая Прибыль Валюте '0'--> Нельзя
sinput double             TargetLoss_1               = 1000000;          // Общий Убыток Валюте '0'--> Нельзя
sinput group "----------------- Balans BUY+SELL ----------------------"
sinput double             TargetProfit_2             = 1000000;          // BUY+SELL Прибыль Валюте '0'--> Нельзя
sinput double             TargetLoss_2               = 1000000;          // BUY+SELL Убыток Валюте '0'--> Нельзя
sinput group "----------------- TP SL In currency --------------------"
sinput double             InpTProfit                 = 40000;            // In currency the amount Общий TP
sinput double             InpStopLoss                = 1000000;          // In currency the amount Общий SL
sinput ENUM_P             InpProfitCommand           = tpl_b;            // TP SL: command Close
sinput string             Template_1                 = "Momentum";       // Имя шаблона(without '.tpl')
sinput group "----------------- Lots Parameters ----------------------"
sinput double             InpLots1                   = 0.01;             // : Lots 1
sinput int                InpLots_01                 = 3000;             // In currency the amount
sinput double             InpLots2                   = 0.02;             // : Lots 2
sinput int                InpLots_02                 = 6000;             // In currency the amount
sinput double             InpLots3                   = 0.04;             // : Lots 3
sinput int                InpLots_03                 = 12000;            // In currency the amount
sinput double             InpLots4                   = 0.08;             // : Lots 4
sinput group "----------------- Start Stop ---------------------------"
sinput datetime           HoursFrom                  = D'1970.01.02';    // 1 Время: старт
sinput datetime           HoursTo                    = D'1970.01.01';    // Время: стоп
sinput datetime           HoursFrom2                 = D'1970.01.01';    // 2 Время: старт
sinput group "----------------- Time:Start Stop ----------------------"
sinput int                HoursFrom1                 = 0;                // Время: старт
sinput int                HoursTo1                   = 24;               // Время: стоп
sinput group "----------------- Obj: VLine:UP ------------------------"
sinput ENUM_MODE          FilterLine_1               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjVLineName            = "Имя VLine";      // Name: VLine
sinput ENUM_TRADE_COMMAND InpVLineCommand            = Turn_Off;         // VLine command:
sinput group "----------------- Obj: VLine:DOWN ----------------------"
sinput ENUM_MODE          FilterLine_2               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjVLineNameD           = "Имя VLine";      // Name: VLine
sinput ENUM_TRADE_COMMAND InpVLineCommandD           = Turn_Off;         // VLine command:
sinput group "----------------- Indicators: UP -----------------------"
sinput bool               InpIndicators_1            = false;            // Indicators: Start (true)
sinput ENUM_MODE          FilterLine_3               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             short_name_1               = "Имя Индикатора"; // Name Indicators "UP"
sinput int                InpBars_1                  = 1;                // Bars
sinput ENUM_TIMEFRAMES    Period_1                   = PERIOD_CURRENT;   // Period Indicators
sinput ENUM_TRADE_COMMAND InpLongOpened_1Command     = close_open_b;     // Buy command:
sinput ENUM_TRADE_COMMAND InpShortOpened_1Command    = close_open_s;     // Sell command:
sinput group "----------------- Indicators: DOWN ---------------------"
sinput bool               InpIndicators_2            = false;            // Indicators: Start (true)
sinput ENUM_MODE          FilterLine_4               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             short_name_2               = "Имя Индикатора"; // Name Indicators "DOWN"
sinput int                InpBars_2                  = 1;                // Bars
sinput ENUM_TIMEFRAMES    Period_2                   = PERIOD_CURRENT;   // Period Indicators
sinput ENUM_TRADE_COMMAND InpLongOpened_2Command     = close_open_b;     // Buy command:
sinput ENUM_TRADE_COMMAND InpShortOpened_2Command    = close_open_s;     // Sell command:
sinput group "----------------- Trailing Line:UP ---------------------"
sinput bool               InpStartOpen               = false;            // Start Trailing Line
sinput ENUM_MODE          FilterLine_5               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjUpNameOpen           = "openup";         // Obj: Up (Trailing Horizontal Line)
sinput ENUM_TRADE_COMMAND InpTradeCommandY1          = open_sell;        // Trade command:
sinput color              InpObjUpclrOpen            = clrBlue;          // Obj: command: MonitoringColor, EA only monitors this lines color
sinput ENUM_MODE          FilterLine_6               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjDownNameOpen         = "opendown";       // Obj: Down (Trailing Horizontal Line)
sinput ENUM_TRADE_COMMAND InpTradeCommandU1          = open_buy;         // Trade command:
sinput color              InpObjDownclrOpen          = clrRed;           // Obj: command: MonitoringColor, EA only monitors this lines color
sinput double             InpObjTrailingStopOpen     = 0;                // Obj: Trailing Stop (distance from price to object, in pips)
sinput double             InpObjTrailingStepOpen     = 0;                // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
sinput group "----------------- Trailing Line:DOWN -------------------"
sinput bool               InpStartClos               = false;            // Start Trailing Line
sinput ENUM_MODE          FilterLine_7               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjUpNameClos           = "closup";         // Obj: Up (Trailing Horizontal Line)
sinput ENUM_TRADE_COMMAND InpTradeCommandY2          = close_sells;      // Trade command:
sinput color              InpObjUpclrClos            = clrBlue;          // Obj: command: MonitoringColor, EA only monitors this lines color
sinput ENUM_MODE          FilterLine_8               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjDownNameClos         = "closdown";       // Obj: Down (Trailing Horizontal Line)
sinput ENUM_TRADE_COMMAND InpTradeCommandU2          = close_buys;       // Trade command:
sinput color              InpObjDownclrClos          = clrRed;           // Obj: command: MonitoringColor, EA only monitors this lines color
sinput double             InpObjTrailingStopClos     = 0;                // Obj: Trailing Stop (distance from price to object, in pips)
sinput double             InpObjTrailingStepClos     = 0;                // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
sinput group "----------------- Buy::UP ------------------------------"
sinput ENUM_MODE          FilterLine_9               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput ENUM_TRADE_COMMAND InpColorBuyCommand         = open_buy;         // Trade command:
sinput color              MonitoringColorBuy         = clrGold;          // Buy MonitoringColor, EA only monitors this lines color
sinput color              CrossedColorBuy            = clrGreen;         // CrossedColor, EA changes crossed lines color to this value
sinput bool               EnableAlertsBuy            = false;            // EnableAlertsBuy
sinput bool               EnableNotificationsBuy     = false;            // EnableNotificationsBuy
sinput bool               EnableEmailsBuy            = false;            // EnableEmailsBuy
sinput group "----------------- Sell::DOWN ---------------------------"
sinput ENUM_MODE          FilterLine_10              = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput ENUM_TRADE_COMMAND InpColorSellCommand        = open_sell;        // Trade command:
sinput color              MonitoringColorSell        = clrYellow;        // Sell MonitoringColor, EA only monitors this lines color
sinput color              CrossedColorSell           = clrGreen;         // CrossedColor, EA changes crossed lines color to this value
sinput bool               EnableAlertsSell           = false;            // EnableAlertsSell
sinput bool               EnableNotificationsSell    = false;            // EnableNotificationsSell
sinput bool               EnableEmailsSell           = false;            // EnableEmailsSell
sinput group "----------------- Close Buy::UP ------------------------"
sinput ENUM_MODE          FilterLine_11              = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput ENUM_TRADE_COMMAND InpCloseBuyCommand         = close_buys;       // Trade command:
sinput color              MonitoringColorClosBuy     = clrOrangeRed;     // Close Buy MonitoringColor, EA only monitors this lines color
sinput color              CrossedColorClosBuy        = clrGreen;         // CrossedColor, EA changes crossed lines color to this value
sinput bool               EnableAlertsClosBuy        = false;            // EnableAlertsClosBuy
sinput bool               EnableNotificationsClosBuy = false;            // EnableNotificationsClosBuy
sinput bool               EnableEmailsClosBuy        = false;            // EnableEmailsClosBuy
sinput group "----------------- Close Sell::DOWN ---------------------"
sinput ENUM_MODE          FilterLine_12              = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput ENUM_TRADE_COMMAND InpCloseSellCommand        = close_sells;      // Trade command:
sinput color              MonitoringColorClosSell    = clrMagenta;       // Close Sell MonitoringColor, EA only monitors this lines color
sinput color              CrossedColorClosSell       = clrGreen;         // CrossedColor, EA changes crossed lines color to this value
sinput bool               EnableAlertsClosSell       = false;            // EnableAlertsClosSell
sinput bool               EnableNotificationsClosSell= false;            // EnableNotificationsClosSell
sinput bool               EnableEmailsClosSell       = false;            // EnableEmailsClosSell
sinput group "----------------- Button: ------------------------------"
sinput ENUM_TRADE_COMMAND InpTradeCommandBuy         = open_buy;         // Obj(BUY):
sinput ENUM_TRADE_COMMAND InpTradeCommandSell        = open_sell;        // Obj(SELL):
sinput ENUM_TRADE_COMMAND InpTradeCommandClosBuy     = close_buys;       // Obj(ClosBuy):
sinput ENUM_TRADE_COMMAND InpTradeCommandClosSell    = close_sells;      // Obj(ClosSell):
sinput group "----------------- FILTER:Command -----------------------"
sinput ENUM_FILTR_COMMAND ObjFilterStopUp            = Filter_Off;       // Filter
sinput string             InpNameupper               = "Линии Up";       // FILTER Upper (Horizontal Line or Trend Line)
sinput ENUM_FILTR_COMMAND ObjFilterStopLow           = Filter_Off;       // Filter
sinput string             InpNamelower               = "Линии Low";      // FILTER Lower (Horizontal Line or Trend Line)
sinput group "----------------- :(+): Line:Middle --------------------"
sinput string             InpNameaverageUp           = "Middle:Up";      // FILTER Up (Horizontal Line or Trend Line)
sinput string             InpNameaverageLow          = "Middle:Low";     // FILTER Low (Horizontal Line or Trend Line)
//+------------------------------------------------------------------+
ushort   InpSignalsFrequency=1;  // Search signals, in seconds (min value "1")
uint     maxLimits=1;            // Кол-во Позиции Открыть в одну сторону
uint     SLEEPTIME=1;            // Время паузы между повторами в секундах
uint     Deviation=10;           // Отклонение цены
bool     ObjRevers=false;        // Revers
//+------------------------------------------------------------------+
bool     ExtTurnOff              = false;    //
bool     ExttplAll               = false;    //
bool     ExtUpName               = false;    //
bool     ExtDownName             = false;    //
bool     ClExtUpName             = false;    //
bool     ClExtDownName           = false;    //
bool     ExtNeedCloseBuy         = false;    //
bool     ExtNeedCloseSell        = false;    //
bool     ExtNeedCloseAll         = false;    //
bool     ExtNeedOpenBuy          = false;    //
bool     ExtNeedOpenSell         = false;    //
bool     ExtAllCloseAll          = false;    //
bool     ExtCloseAll             = false;    //
bool     ExtFilter_Off           = false;    //
bool     ExtFilter_Stop          = false;    //
bool     ExtFilter_All           = false;    //
bool     ExMode_All              = false;    //
bool     ExMode_Ind              = false;    //
string   m_name[]= {"BUY","SELL","BUY_Close","SELL_Close","CLOSE_ALL","without '.tpl'"};
//+------------------------------------------------------------------+
//| MACD Sample expert class                                         |
//+------------------------------------------------------------------+
class CSampleExpert
  {
protected:

это кому Интересно может в тестере потренироваться 
 

Файлы:
EXP_0005.mq5  232 kb
 

Как работает функция Фильтра 

сам участок в коде 

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void CSampleExpert::OnTickInpUpper(void)
  {
   if(InpSignalsFrequency>=SLEEPTIME) // search for trading signals no more than once every 1 seconds
     {
      datetime time_current=TimeCurrent();
      if(time_current-ExtLastUpper>SLEEPTIME)
        {
         MqlRates rates[],rates_1[];
         //ArraySetAsSeries(rates,true);
         int start_pos=0,count=1;
         if(CopyRates(m_symbol.Name(),Period(),start_pos,count,rates)!=count)
           {
            ExtPrevUpper=0;
            return;
           }
         int start_pos_1=0,count_1=1;
         if(CopyRates(m_symbol.Name(),Period(),start_pos_1,count_1,rates_1)!=count_1)
           {
            ExtPrevAverage=0;
            return;
           }
         double price_line=0.0,price_line_1=0.0;
         if(ObjectFind(0,InpNameaverageUp)>=0 || ObjectFind(0,InpNameupper)>=0)
           {
            long object_type_1=ObjectGetInteger(0,InpNameaverageUp,OBJPROP_TYPE);
            if(object_type_1==OBJ_HLINE)
               price_line_1=ObjectGetDouble(0,InpNameaverageUp,OBJPROP_PRICE);
            else
               if(object_type_1==OBJ_TREND)
                  price_line_1=ObjectGetValueByTime(0,InpNameaverageUp,rates_1[0].time,0);
            long object_type=ObjectGetInteger(0,InpNameupper,OBJPROP_TYPE);
            if(object_type==OBJ_HLINE)
               price_line=ObjectGetDouble(0,InpNameupper,OBJPROP_PRICE);
            else
               if(object_type==OBJ_TREND)
                  price_line=ObjectGetValueByTime(0,InpNameupper,rates[0].time,0);
            if(price_line>0.0 || price_line_1>0.0)
              {
               switch(ObjFilterStopUp)
                 {
                  case Filter_Off:
                     ExtFilter_Off=true;
                     break;
                  case Filter_Stop:
                     ExtFilter_Stop=true;
                     if(rates[0].open>price_line)
                       {
                        ProcessingUp();
                       }
                     break;
                  case Filter_All:
                     ExtFilter_All=true;
                     if(rates[0].open<price_line && rates_1[0].close>price_line_1)
                       {
                        ProcessingUp();
                       }
                     break;
                 }
              }
           }
         ExtLastUpper=time_current;
         ExtLastAverage=time_current;
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void CSampleExpert::OnTickInpLower(void)
  {
   if(InpSignalsFrequency>=SLEEPTIME) // search for trading signals no more than once every 1 seconds
     {
      datetime time_current=TimeCurrent();
      if(time_current-ExtLastLower>SLEEPTIME)
        {
         MqlRates rates[],rates_1[];
         //ArraySetAsSeries(rates,true);
         int start_pos=0,count=1;
         if(CopyRates(m_symbol.Name(),Period(),start_pos,count,rates)!=count)
           {
            ExtPrevLower=0;
            return;
           }
         int start_pos_1=0,count_1=1;
         if(CopyRates(m_symbol.Name(),Period(),start_pos_1,count_1,rates_1)!=count_1)
           {
            ExtPrevAverage=0;
            return;
           }
         double price_line=0.0,price_line_1=0.0;
         if(ObjectFind(0,InpNameaverageLow)>=0 || ObjectFind(0,InpNamelower)>=0)
           {
            long object_type_1=ObjectGetInteger(0,InpNameaverageLow,OBJPROP_TYPE);
            if(object_type_1==OBJ_HLINE)
               price_line_1=ObjectGetDouble(0,InpNameaverageLow,OBJPROP_PRICE);
            else
               if(object_type_1==OBJ_TREND)
                  price_line_1=ObjectGetValueByTime(0,InpNameaverageLow,rates_1[0].time,0);
            long object_type=ObjectGetInteger(0,InpNamelower,OBJPROP_TYPE);
            if(object_type==OBJ_HLINE)
               price_line=ObjectGetDouble(0,InpNamelower,OBJPROP_PRICE);
            else
               if(object_type==OBJ_TREND)
                  price_line=ObjectGetValueByTime(0,InpNamelower,rates[0].time,0);
            if(price_line>0.0 || price_line_1>0.0)
              {
               switch(ObjFilterStopLow)
                 {
                  case Filter_Off:
                     ExtFilter_Off=true;
                     break;
                  case Filter_Stop:
                     ExtFilter_Stop=true;
                     if(rates[0].open<price_line)
                       {
                        ProcessingDown();
                       }
                     break;
                  case Filter_All:
                     ExtFilter_All=true;
                     if(rates[0].open>price_line && rates_1[0].close<price_line_1)
                       {
                        ProcessingDown();
                       }
                     break;
                 }
              }
           }
         ExtLastLower=time_current;
         ExtLastAverage=time_current;
        }
     }
  }
//+------------------------------------------------------------------+

А тут распределение 

//+------------------------------------------------------------------+
//| main function returns true if any position processed             |
//+------------------------------------------------------------------+
bool CSampleExpert::Processing(void)
  {
//--- refresh rates
   if(!m_symbol.RefreshRates())
      return(false);
   ButtonOnTick();
   ProfitOnTick();
   ProfitTarget_2();
   ProfitTarget();
   ProfitTarget_1();
   if(InpStartOpen)
     {
      OnTickObjTrailingOpen();
     }
   if(InpStartClos)
     {
      OnTickObjTrailingClos();
     }
//---
   if((HoursFrom<HoursTo && TimeLocal()>=HoursFrom && TimeLocal()<HoursTo) ||
      (HoursFrom>HoursTo && (TimeLocal()<HoursTo || TimeLocal()>=HoursFrom)) ||
      (HoursFrom2<HoursTo2 && TimeLocal()>=HoursFrom2 && TimeLocal()<HoursTo2) ||
      (HoursFrom2>HoursTo2 && (TimeLocal()<HoursTo2 || TimeLocal()>=HoursFrom2)))
     {
      MqlDateTime currTime;
      TimeLocal(currTime);
      int hour0 = currTime.hour;
      if((HoursFrom1 < HoursTo1 && hour0 >= HoursFrom1 && hour0 < HoursTo1) ||
         (HoursFrom1 > HoursTo1 && (hour0 < HoursTo1 || hour0 >= HoursFrom1)))
        {
         OnTickInpUpper();
         OnTickInpLower();
         ProcessingFilter();
         switch(ObjFilterStopUp)
           {
            case Filter_Off:
               ExtFilter_Off=true;
               ProcessingUp();
               break;
           }
         switch(ObjFilterStopLow)
           {
            case Filter_Off:
               ExtFilter_Off=true;
               ProcessingDown();
               break;
           }
        }
     }
//--- exit without position processing
   return(false);
  }
//+------------------------------------------------------------------+
//| main function returns true if any position processed             |
//+------------------------------------------------------------------+
bool CSampleExpert::ProcessingFilter(void)
  {
//--- refresh rates
   if(!m_symbol.RefreshRates())
      return(false);
   switch(FilterLine_1)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         ObjVLinetime();
         break;
     }
   switch(FilterLine_2)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         ObjVLinetimeD();
         break;
     }
   switch(FilterLine_3)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         Processing_1();
         break;
     }
   switch(FilterLine_4)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         Processing_2();
         break;
     }
   switch(FilterLine_5)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         OnTickInpNameRx();
         break;
     }
   switch(FilterLine_6)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         OnTickInpNameSx();
         break;
     }
   switch(FilterLine_7)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         OnTickInpNameRz();
         break;
     }
   switch(FilterLine_8)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         OnTickInpNameSz();
         break;
     }
   switch(FilterLine_9)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         ProcessingBuy();
         break;
     }
   switch(FilterLine_10)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         ProcessingSell();
         break;
     }
   switch(FilterLine_11)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         ProcessingClosBuy();
         break;
     }
   switch(FilterLine_12)
     {
      case mode_All:
         ExMode_All=true;
         break;
      case mode_Ind:
         ExMode_Ind=true;
         ProcessingClosSell();
         break;
     }
//--- exit without position processing
   return(false);
  }
//+------------------------------------------------------------------+
//| main function returns true if any position processed             |
//+------------------------------------------------------------------+
bool CSampleExpert::ProcessingUp(void)
  {
//--- refresh rates
   if(!m_symbol.RefreshRates())
      return(false);
   Processing_1();
   ObjVLinetime();
   OnTickInpNameRx();
   OnTickInpNameSx();
   ProcessingBuy();
   ProcessingClosBuy();
//--- exit without position processing
   return(false);
  }
//+------------------------------------------------------------------+
//| main function returns true if any position processed             |
//+------------------------------------------------------------------+
bool CSampleExpert::ProcessingDown(void)
  {
//--- refresh rates
   if(!m_symbol.RefreshRates())
      return(false);
   Processing_2();
   ObjVLinetimeD();
   OnTickInpNameRz();
   OnTickInpNameSz();
   ProcessingSell();
   ProcessingClosSell();
//--- exit without position processing
   return(false);
  }
//+------------------------------------------------------------------+

как его использовать в настройках 

sinput group "----------------- FILTER:Command -----------------------"
sinput ENUM_FILTR_COMMAND ObjFilterStopUp            = Filter_Off;       // Filter
sinput string             InpNameupper               = "Линии Up";       // FILTER Upper (Horizontal Line or Trend Line)
sinput ENUM_FILTR_COMMAND ObjFilterStopLow           = Filter_Off;       // Filter
sinput string             InpNamelower               = "Линии Low";      // FILTER Lower (Horizontal Line or Trend Line)
sinput group "----------------- :(+): Line:Middle --------------------"
sinput string             InpNameaverageUp           = "Middle:Up";      // FILTER Up (Horizontal Line or Trend Line)
sinput string             InpNameaverageLow          = "Middle:Low";     // FILTER Low (Horizontal Line or Trend Line)
//+------------------------------------------------------------------+
 
SanAlex:

Как работает функция Фильтра 

сам участок в коде 

А тут распределение 

как его использовать в настройках 

Попытаюсь объяснить функцию фильтра 

P - связана с каждой по отдельности R0 отдельно с P и S0  отдельно с P


FILTR

есть второй режим - где нет Middle 

тогда в место R0 и S0 - пишем там и там P -----------------  получится выше жёлтой UP будут работать а ниже жёлтой DOWN будут работать 

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

с такими настройками как на картинке - в синем квадрате будет работать сигнал, выше квадрата фильтр запретит сигнал, так же и с красным квадратом от жёлтой до первой красной линии сигнал будет поступать, выйдя за приделы красной линии фильтр не позволит открыть позицию 

FILTR 2 

 

Сигналы можно получить. ОТ

1. Двух Индикаторов.

2. Двух Вертикальных линии.

3. Четырёх Горизонтальных или Трендовых линии по имени. 

4. Четырёх Горизонтальных или Трендовых линии по цвету. 

Итого 12 сигналов. 

 

Запустил Эксперта на проверку работоспособности.

proverka

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Предыдущий Эксперт https://www.mql5.com/ru/code/30444 почти такой же. Всё ищу для него прибыльные настройки 

по графику видно как я пытаюсь подбирать ему настройки

proverka 2 

 
SanAlex:

Сигналы можно получить. ОТ

1. Двух Индикаторов.

2. Двух Вертикальных линии.

3. Четырёх Горизонтальных или Трендовых линии по имени. 

4. Четырёх Горизонтальных или Трендовых линии по цвету. 

Итого 12 сигналов. 

Что Важно запомнить из этих сигналов - Это четыре линии где можно почти в любом алгоритме использовать.

//+------------------------------------------------------------------+
//| ENUM_TRADE_COMMAND                                               |
//+------------------------------------------------------------------+
enum ENUM_TRADE_COMMAND
  {
   Turn_Off=0,        // TURN OFF
   tpl=1,             // '.tpl' All
   Close_AllExt=2,    // CloseAll + ExpertRemoves
   Close_All_All=3,   // CloseAll
   close_tpl_b=4,     // Close Sell + Open Buy + '.tpl'
   close_tpl_s=5,     // Close Buy + Open Sell + '.tpl'
   close_all_tpl=6,   // Close Buy's Sell's + '.tpl'
   UpName=7,          // Line Open UpName
   DownName=8,        // Line Open DownName
   UpName_s=9,        // Line Open UpName + Open Sell
   UpName_b=10,       // Line Open UpName + Open Buy
   DownName_b=11,     // Line Open DownName + Open Buy
   DownName_s=12,     // Line Open DownName + Open Sell
   ClUpName=13,       // Line Close UpName
   ClDownName=14,     // Line Close DownName
   ClUpName_s=15,     // Line Close UpName + Open Sell
   ClUpName_b=16,     // Line Close UpName + Open Buy
   ClDownName_b=17,   // Line Close DownName + Open Buy
   ClDownName_s=18,   // Line Close DownName + Open Sell
   close_buys=19,     // Close All Buy's
   close_sells=20,    // Close All Sell's
   close_all=21,      // Close All Buy's and Sell's
   open_buy=22,       // Open  Buy
   open_sell=23,      // Open  Sell
   close_open_b=24,   // Close Sell + Open Buy
   close_open_s=25,   // Close Buy + Open Sell
   open_buy_sell=26,  // Open  Buy and Sell
  };
//+------------------------------------------------------------------+

находятся они в этой функции Трал.

что бы они автоматически отпрыгивали нужно задать расстояние (отмечено жёлтым) 

sinput group "----------------- Trailing Line:UP ---------------------"
sinput bool               InpStartOpen               = false;            // Start Trailing Line
sinput ENUM_MODE          FilterLine_5               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjUpNameOpen           = "openup";         // Obj: Up (Trailing Horizontal Line)
sinput ENUM_TRADE_COMMAND InpTradeCommandY1          = open_sell;        // Trade command:
sinput color              InpObjUpclrOpen            = clrBlue;          // Obj: command: MonitoringColor, EA only monitors this lines color
sinput ENUM_MODE          FilterLine_6               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjDownNameOpen         = "opendown";       // Obj: Down (Trailing Horizontal Line)
sinput ENUM_TRADE_COMMAND InpTradeCommandU1          = open_buy;         // Trade command:
sinput color              InpObjDownclrOpen          = clrRed;           // Obj: command: MonitoringColor, EA only monitors this lines color
sinput double             InpObjTrailingStopOpen     = 0;                // Obj: Trailing Stop (distance from price to object, in pips)
sinput double             InpObjTrailingStepOpen     = 0;                // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
sinput group "----------------- Trailing Line:DOWN -------------------"
sinput bool               InpStartClos               = false;            // Start Trailing Line
sinput ENUM_MODE          FilterLine_7               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjUpNameClos           = "closup";         // Obj: Up (Trailing Horizontal Line)
sinput ENUM_TRADE_COMMAND InpTradeCommandY2          = close_sells;      // Trade command:
sinput color              InpObjUpclrClos            = clrBlue;          // Obj: command: MonitoringColor, EA only monitors this lines color
sinput ENUM_MODE          FilterLine_8               = mode_All;         // FILTER: ВКЛ.ВЫКЛ.
sinput string             InpObjDownNameClos         = "closdown";       // Obj: Down (Trailing Horizontal Line)
sinput ENUM_TRADE_COMMAND InpTradeCommandU2          = close_buys;       // Trade command:
sinput color              InpObjDownclrClos          = clrRed;           // Obj: command: MonitoringColor, EA only monitors this lines color
sinput double             InpObjTrailingStopClos     = 0;                // Obj: Trailing Stop (distance from price to object, in pips)
sinput double             InpObjTrailingStepClos     = 0;                // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
 
Фриланс в помощь
 
Vladimir Baskakov:
Фриланс в помощь

Владимир Вы о чём? Все труды раздаю бесплатно. Пользуйтесь на Здоровья! 

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

Здесь можно скачать https://www.mql5.com/ru/code/34046  

Algorithm manually automate
Algorithm manually automate
  • www.mql5.com
Эксперт для Автоматизации Ручной торговли.
Причина обращения: