How I assemble my advisor by trial and error - page 50

 
Alexsandr San:

Added this feature to the Utility ("Utility Command") #property version "1.004"

at the bottom, settings for this function

name of trend line or horizontal line - to install Indicator

indicator name - which indicator you want to install on the chart

name of horizontal or trend line of the Indicator

-------------------------- the principle of work, should be as follows

----------------------- The indicator will move the horizontal line (blue) - if it breaks through, it will open in SELL and remove the indicator and set a yellow line, which will be picked up by another indicator and will move the line to the purple level of the indicator - after the, horizontal yellow, again will set the indicator


The function works perfectly - the Utility, very, not bad turned out .

However, it is necessary to add to this function, more setting, which will set the Indicator, through the number of points from the open position

Photo by

 
Alexsandr San:

Added this feature to the Utility ("Utility Command") #property version "1.004"

at the bottom, settings for this function

name of trend line or horizontal line - to install Indicator

indicator name - which indicator you want to install on the chart

name of horizontal or trend line of the Indicator

-------------------------- the principle of work, should be as follows

----------------------- The indicator will move the horizontal line (blue) - if it breaks through, it will open in SELL and remove the indicator and set the yellow line, which will be picked up by another indicator and will move the line to the purple level of the Indicator - after, the horizontal yellow line, again set the Indicator


minor corrections in the code, in//| Function to check and add indicator to the chart |

#property version "1.005"

//+------------------------------------------------------------------+
//| Функция проверки и добавления индикатора на график               |
//+------------------------------------------------------------------+
bool AddIndicator()
  {
//--- выводимое сообщение
   string message;
//--- проверим на совпадение символ индикатора и символ графика
   if(_Symbol!=_Symbol)
     {
      message="Демонстрация использования функции Demo_ChartIndicatorAdd():";
      message=message+"\r\n";
      message=message+"Нельзя на график добавить индикатор, рассчитанный на другом символе.";
      message=message+"\r\n";
      message=message+"Укажите в свойствах эксперта символ графика - "+_Symbol+".";
      Alert(message);
      //--- досрочный выход, не будем добавлять индикатор на график
      return false;
     }
//--- проверим на совпадение таймфрейм индикатора и таймфрейм графика
   if(_Period!=_Period)
     {
      message="Нельзя на график добавить индикатор, рассчитанный на другом таймфрейме.";
      message=message+"\r\n";
      message=message+"Укажите в свойствах эксперта таймфрейм графика - "+EnumToString(_Period)+".";
      Alert(message);
      //--- досрочный выход, не будем добавлять индикатор на график
      return false;
     }
//--- все проверки прошли, символ и период индикатора соответствуют графику
   if(indicator_handle==INVALID_HANDLE)
     {
      Print(__FUNCTION__,"  Создаем индикатор");
      indicator_handle=iCustom(_Symbol,_Period,Inpshort_name);
      if(indicator_handle==INVALID_HANDLE)
        {
         Print("Не удалось создать индикатор. Код ошибки ",GetLastError());
        }
     }
//--- сбросим код ошибки
   ResetLastError();
//--- накладываем индикатор на график
   Print(__FUNCTION__,"  Добавляем индикатор на график");
   Print("Индикатор построен на ",_Symbol,"/",EnumToString(_Period));
//--- получим номер нового подокна, в которое добавим индикатор
   int subwindow=(int)ChartGetInteger(0,-1);
   PrintFormat("Добавляем индикатор на окно %d графика",subwindow);
   if(!ChartIndicatorAdd(0,subwindow,indicator_handle))
     {
      PrintFormat("Не удалось добавить индикатор на окно %d графика. Код ошибки  %d",
                  subwindow,GetLastError());
     }
//--- добавление индикатора на график прошло успешно
   return(true);
  }
//+------------------------------------------------------------------+
Files:
 
Alexsandr San:

minor corrections in the code, in//| Function for checking and adding indicator to the chart |

#property version "1.005"

slightly tweaked the code

#property version "1.006"

input string   t1="----- Trailing Line: 2   -----";              //
input string   InpObjUpNameG                = "POT";             // Obj: TOP (Horizontal Line)
input int      InpStep3                     = 0;                 // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommandG   = close_open_b;      // Obj:  command:
input string   InpObjDownNameG              = "REWOL";           // Obj: LOWER (Horizontal Line)
input int      InpStep4                     = 0;                 // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommandG    = close_open_s;      // Obj:  command:
input ushort   InpObjTrailingStopG          = 0;                 // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepG          = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
input string   t9="------ ChartIndicatorAdd -----";              //
input bool     InpChartInd                  = false;             // Avto Line Chart Indicators
input string   InpIndiL                     = "AVERAGE 0";       // Line name (ChartIndicatorAdd)
input int      InpStep5                     = 15;                // Obj: Шаг сетки, пунктов("0" -> false)
input string   InpIndi_name                 = "Indicator";       // INDICATOR_SHORTNAME

from"AVERAGE 0"; will set Horizontal line "POT"; and "REWOL"; at specified distance =0;// Obj: Step of grid, pips("0" -> false)

if set =true( = false; // Avto Line Chart Indicators ) will be repeated at the given distance from the line "AVERAGE 0";

Files:
 

All day and all night - but I got what I wanted Thank you! Thank you very much !!! VladimirKarputov

one signal by time !!! Here is a function

input string   t="-----  Parameters         -----";              //
input datetime InpMonday_1                  = D'1980.07.19 10:00:00'; // Monday time 1 (use only HH::MM) (00::00 -> off)
//+------------------------------------------------------------------+
long     m_monday_1= 0;

int OnInit()
  {
//---
   MqlDateTime STime;
//--- Monday
   TimeToStruct(InpMonday_1,STime);
   m_monday_1=STime.hour*60*60+STime.min*60;
//---
   return(INIT_SUCCEEDED);
  }

void OnTick()
  {
      TimeSession();

  }


//+------------------------------------------------------------------+
//| Search trading signals                                                                 |
//+------------------------------------------------------------------+
bool TimeSession()
  {
   bool res=false;
//---
   MqlDateTime STimeCurrent;
   TimeToStruct(TimeCurrent(),STimeCurrent);
   long time_current=STimeCurrent.hour*60*60+STimeCurrent.min*60+STimeCurrent.sec;
   if(m_monday_1==0)
      return(true);
//--- Monday time 1
   if(m_monday_1!=0 && (time_current>=m_monday_1 && time_current<m_monday_1+60))
     {
      datetime last_setup=0;
      MqlDateTime SLastSetup;
      TimeToStruct(last_setup,SLastSetup);
      long time_last_setup=SLastSetup.hour*60*60+SLastSetup.min*60+SLastSetup.sec;
      if(SLastSetup.day_of_week==1 && (time_last_setup>=m_monday_1 && time_last_setup<m_monday_1+60))
         return(true);
      if(1>0)
        {
         Sleep(59*1000);
         PlaySound("tick.wav");
        }
      res=true;
     }
//---
   return(true);
  }
//+------------------------------------------------------------------+
Vladimir Karputov
Vladimir Karputov
  • www.mql5.com
Люди. Граждане! Огромная просьба - заполняйте свой профиль на сайте и пользуйтесь стандартными программами - устанавливайте Skype. У Skype есть очень полезная функция - показ рабочего стола. В таком случае можно оперативно подсказать по возникшей проблеме. Помните - время - деньги! Древняя народная мудрость гласит: если хочешь помочь...
 
Alexsandr San:

tweaked the code a bit

#property version "1.006"

from"AVERAGE 0"; will expose the Horizontal lines "POT"; and "REWOL"; at a given distance = 0;// Obj: Grid Step, pips("0" -> false)

if set =true( = false; // Avto Line Chart Indicators ) will be repeated at the set distance from the line "AVERAGE 0" ;

#property version "1.007"
Added - by Time, set Indicator, Horizontal lines, which are set at what distance, from the price.

as well as for Time, close all positions and delete the Expert Advisor and change charts or simply, without deleting any open positions, delete the Expert Advisor and change the Chart Template .

Here is its settings

//+------------------------------------------------------------------+
input string   t="-----  Parameters         -----";              //
input string   Template                     = "ADX";             // Имя шаблона(without '.tpl')
input bool     Inpwithout                   = false;             // Сменить только шаблон (true)
input datetime InpMonday_2                  = D'1970.01.01';     // Dell (00::00 -> off)
input double   TargetProfit                 = 999999.99;         // Цель Баланса(Ваш Баланс + сумма)
input uint     maxLimits                    = 1;                 // Кол-во Позиции Открыть в одну сторону
input double   InpLots                      = 0.01;              // Lots
input int      InpTakeProfit                = 90;                // Take Profit ("0"-No. 5<100)
input string   t0="----- Trailing Line: 1   -----";              //
input string   InpObjUpName                 = "ZTOP";            // Obj: TOP (Horizontal Line)
input int      InpStep1                     = 25;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommand    = open_sell;         // Obj:  command:
input string   InpObjDownName               = "ZLOWER";          // Obj: LOWER (Horizontal Line)
input int      InpStep2                     = 25;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommand     = open_buy;          // Obj:  command:
input ushort   InpObjTrailingStop           = 0;                 // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStep           = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
input string   t2="----- Indicators: SELL   -----";              //
input string   short_name                   = "LeMan_BrainTrend1Sig";   // Name Indicators "SELL"
input bool     InpIndicators                = false;             // Indicators: Start (true)
input ENUM_TRADE_COMMAND InpTradeCommandY   = open_sell;         // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU   = close_sells;       // Trade command: (SellBuffer Indicators)
input string   t3="----- Indicators: BUY    -----";              //
input string   short_name1                  = "LeMan_BrainTrend1Sig";   // Name Indicators "BUY"
input bool     InpIndicators1               = false;             // Indicators: Start (true)
input ENUM_TRADE_COMMAND InpTradeCommandY1  = close_buys;        // Trade command: (BuyBuffer Indicators)
input ENUM_TRADE_COMMAND InpTradeCommandU1  = open_buy;          // Trade command: (SellBuffer Indicators)
input string   t4="----- Button:            -----";              //
input ENUM_TRADE_COMMAND InpTradeCommandBut = open_buy;          // Obj(BUY):  command:Button: BUY
input ENUM_TRADE_COMMAND InTradeCommandBut  = open_sell;         // Obj(SELL):  command:Button: SELL
input int      TrailingStop_STOP_LEVEL      = 36;                // Button: Trailing Stop LEVEL
input string   t5="----- Line name: 1       -----";              //
input string   InpNameR                     = "LineR";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandR   = open_buy;          // Trade command:
input string   t6="----- Line name: 2       -----";              //
input string   InpNameS                     = "LineS";           // Line name (Horizontal Line or Trend Line)
input ENUM_TRADE_COMMAND InpTradeCommandS   = open_sell;         // Trade command:
input string   t7="----- Revers Buy><Sell   -----";              //
input bool     ObjRevers                    = false;             //  Revers
input string   t8="------ Indicator Delete  -----";              //
input string   Inpshort_name_1              = "Indicator 2";     // INDICATOR_SHORTNAME 2
input bool     Inpres                       = false;             // Delete All Indicators
input string   t1="----- Trailing Line: 2   -----";              //
input string   InpObjUpNameG                = "POT";             // Obj: TOP (Horizontal Line)
input int      InpStep3                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InpTradeCommandG   = close_open_b;      // Obj:  command:
input string   InpObjDownNameG              = "REWOL";           // Obj: LOWER (Horizontal Line)
input int      InpStep4                     = 20;                // Obj: Шаг сетки, пунктов("0" -> false)
input ENUM_TRADE_COMMAND InTradeCommandG    = close_open_s;      // Obj:  command:
input ushort   InpObjTrailingStopG          = 0;                 // Obj: Trailing Stop (distance from price to object, in pips)
input ushort   InpObjTrailingStepG          = 5;                 // Obj: Trailing Step, in pips (1.00045-1.00055=1 pips)
input string   t9="------ ChartIndicatorAdd -----";              //
input bool     InpChartInd                  = false;             // Avto Line Chart Indicators
input string   InpIndiL                     = "AVERAGE 0";       // Line name (ChartIndicatorAdd)
input int      InpStep5                     = 15;                // Obj: Шаг сетки, пунктов("0" -> false)
input string   InpIndi_name                 = "Indicator";       // INDICATOR_SHORTNAME
input datetime InpMonday_1                  = D'1970.01.01';     // Indicators(use only HH::MM)(00::00->off)
//+------------------------------------------------------------------+
Files:
 

The indicator gives Alert - from the Horizontal blue line, we draw one at the top, another one at the bottom and as the blue line crosses, it triggers Alert and deletes the line

- I will add, this function inUtility_Command.mq5225 kb

Photo by

Files:
macd_Line.mq5  21 kb
 

It's not easy to make Horizontal lines work in the Indicator window

but I've kind of worked something out. Here's a rough draft. From macd null line (SELL bottom line break BUY top line)

Photo by

Snapshot2

-------------------------

Expert and Indicator draft

Files:
 
Alexsandr San:

It's not easy to get the Horizontal lines to work in the Indicator Window

but I've kind of worked something out. Here's a rough draft. From macd zero line (SELL bottom line break BUY top line)

-------------------------

a draft of Expert and indicator

In fact, the Expert Advisor works in the Indicator Window - if LOW is a horizontal line, between the BUY and SELL lines it does not open a position, but moves higher than BUY, it opens a BUY position.

conversely, below theSELL line it opens a sell position

AUDCADM1

 
Alexsandr San:

The indicator gives Alert - from the Horizontal blue line, we draw one at the top, another one at the bottom and as the blue line crosses, it triggers Alert and deletes the line

- I will add, this function inUtility_Command.mq5225 kb

I have added this function - it is very simple, but I have only found out how to implement it

#property version "1.008"

AUDCADM1V 1

AUDCADM1B 2

Photo by 3


I attach an indicator for this function

Files:
 

Yes! You should also add this to the Utilityhttps://www.mql5.com/ru/code/23939


OBJ_HLINE follows price
OBJ_HLINE follows price
  • www.mql5.com
GannZIGZAG_Fibo_Grand_xN_Din Зигзаг Ганна с графическим объектом "Уровни Фибоначчи", построенными на двух, последних вершинах с расширенными настройками для отображения фибо-уровней. XKPrmSt_NRTR_HTF