Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1377

 
Michail_David:

I myself did not understand, Alexey, where he dug up this currency pair )))

It happens... Thought about one thing, wrote about another... Same thing myself.........)))

 
Alexey Viktorov:

Either skis are bad... I can't find any mention of this pair in Michail_David's posts... Everywhere it says USDJPY

Wrong track )))) Me ;) I got it wrong.

But in fact - the pair is a string and no inverted commas should be put in it.

@Michail_David

for(int i = SymbolsTotal(in_market_watch) - 1; i >= 0; i--)
   {
      if(StringFind(SymbolName(i,in_market_watch),vlt) >= 0)

vlt - the pair you're looking for (or a bit of it :)))

 
Сергей Таболин:

Wrong track )))) Me ;) I got it wrong.

But in essence - a pair is a string and no inverted commas should be put into it.

@Michail_David

vlt - sought pair (or part of it :)))

Sergey, thank you. I understand the idea.

 

Hello. Please advise.

1. An EA will trade a series of orders (buy-sell-buy-sell-...). The series will end with the order which closed with a profit. How to implement it?

2. The next problem. The first series has not yet been completed (we have not had a profit order), and the second one is already started. How to "split" them for the Expert Advisor?

Thank you.

 
Forallf:

Hello. Please advise.

1. An EA will trade a series of orders (buy-sell-buy-sell-...). The series will end with the order which closed with a profit. How to implement it?

2. The next problem. The first series has not yet been completed (we have not had a profit order), and the second one is already started. How to "split" them for the Expert Advisor?

Thank you.

1 The condition is too vague to help...

2 Use different "magiks"

 

Good afternoon, everyone. Continuing to saw the Grail MachineJ. I have to redo the code with a bias towards using functions, because I'm sick of scrolling through a ton of code. I want to move the functions to separate include files. I have created function for getting signal by ao indicator in EA's file for trial and it works fine.

My robot even opens trades. But if I create a plugin file SIGNALS_INDIKATOR. I connect it in my Expert Advisor like this.

//+------------------------------------------------------------------+
//|                                           TREND+_V_1.0 |
//|                                                    ДАНЯ ГАГАРКИН |
//|                                     https://vk.com/danila_mastep |
//+------------------------------------------------------------------+
#property copyright "ДАНЯ ГАГАРКИН"
#property link      "https://vk.com/danila_mastep"
#property version   "1.00"
#property strict
//НАЧАЛО ВХОДНЫХ ПЕРЕМЕННЫХ И ГЛОБАЛЬНЫХ ПЕРЕМЕННЫХ------------------------------------------------------------------------------------------+
int intBars;// ПЕРЕМЕННАЯ ДЛЯ ОПЕРДЕЛЕНИЯ КОЛИЧЕСТВА БАРОВ, ЧТОБЫ ОПРЕДЕЛИТЬ ПОЯВЛЕНИЕ НОВОГО



#include <TREND+\SIGNALS_INDIKATOR.mqh> 
// А НИЖЕ ПОШЛИ ЕНУМЫ И ЭКСТЕРН ПЕРЕМЕННЫЕ




I also write my function for getting signals by this type of attachment, but this function doesn't show my external variables which I have easily passed to the EA itself. The function of getting indicator's value in my EA is like this.

//НАЧАЛО ПОЛУЧЕНИЯ ДАННЫХ ПО АО СЕЛЛ------------------------------------------------------------------------------------------+
double f_ao_sell()
{ double ao_sell = iCustom(Symbol(),PeriodForWork, //Таймфрейм на котором искать дивергенции

"1)SEARCH_DIVERGENCE",
Params, // Параметры транслирования сигналов
ModeSignalsCTS, // транслировать сигналы в cts?
LifetimeOfSignal, //Время жизни сигнала в баарх рабочего тф
CTS_Name, // имя для cts 
Div_Params, // параметры поиска дивергенции
PeriodForWork, // Таймфрейм на котором искать дивергенции

SearchAccuracy, // Режим поиска совпадений
NumBarAccuracy, // количество баров не точности поиска пиков
KoeffDistanceBetween,// коэффициент разницы между экстремумами
WidthChartLine, // толщина линий на графике цены

WidthIndicatorstLine,// толщина линий в окне индикаторов
ShiftArrow, // смещение значков
AO_Params,  // Параметры АО
UseAO,  // Искать дивергенции на АО
ColorUpperAO,  // цвет верхних линий дивергенций АО
ColorLowerAO, // цвет нижних линий дивергенций АО
Stoch_Params, // параметры стохастик
UseStoch, // искать дивергенции на стохастик
ModeLineSTO, // ИСКАТЬ ДИВЕРГЕНЦИИ ПО ЛИНИИ STOCHASTIC:
Period_K, // период %К стохастик
Period_D, // период %Д стохастик
Slowing, // замедление стохастик
AppledPriceSTO, // цены расчёта стохастик
MethodMAStoch, // метод МА стохастик
UpperLevelSTO, // верхний уровень стохастик
LowerLewelSTO, // нижний уровень стохастик
ColorUpperSTO, // цвет верхних линий дивергенций стохастик
ColorLowerSTO, // ЦВЕТ НИЖНИХ ЛИНИЙ ДИВЕРГЕНЦИЙ STOCHASTIC

RSI_Params, // ПАРАМЕТРЫ RSI
UseRSI, // ИСКАТЬ ДИВЕРГЕНЦИИ НА  RSI?
PeriodRSI, // ПЕРИОД RSI
AppledPriceRSI, // ПРИМЕНИТЬ К
UpperLevelRSI, // ВЕРХНИЙ УРОВЕНЬ RSI
LowerLewelRSI, // НИЖНИЙ УРОВЕНЬ RSI
ColorUpperRSI, // ЦВЕТ ВЕРХНИХ ЛИНИЙ ДИВЕРГЕНЦИЙ RSI
ColorLowerRSI, // ЦВЕТ НИЖНИХ ЛИНИЙ ДИВЕРГЕНЦИЙ RSI
MACD_Params, // ПАРАМЕТРЫ MACD
UseMACD, //  ИСКАТЬ ДИВЕРГЕНЦИИ НА  MACD
ModeLineMACD, //  ИСКАТЬ ДИВЕРГЕНЦИИ ПО ЛИНИИ MACD:
FastEMA_MACD, // БЫСТРОЕ EMA MACD
SlowEMA_MACD, // МЕДЛЕННОЕ EMA MACD
PeriodSignalMACD, // ПЕРИОД СИГНАЛЬНОЙ SMA MACD
AppledPriceMACD, // ПРИМЕНИТЬ К:
ColorUpperMACD, // ЦВЕТ ВЕРХНИХ  ЛИНИЙ ДИВЕРГЕНЦИЙ MACD
ColorLowerMACD, // ЦВЕТ НИЖНИХ ЛИНИЙ ДИВЕРГЕНЦИЙ MACD
Notifications_Params, // ПАРАМЕТРЫ ОПОВЕЩЕНИЙ 
UseAlerts, // ОПОВЕЩАТЬ В ТЕРМИНАЛЕ О СИГНАЛЕ 
UseMail, // ОПОВЕЩАТЬ НА E-MAIL О СИГНАЛЕ 
UsePush, // ОПОВЕЩАТЬ О СИГНАЛЕ НА МОБИЛЬНЫЙ 
2, //ВТОРОЙ БУФЕР- АО СЕЛЛ
0 // СИГНАЛ НА НУЛЕВОЙ СВЕЧЕ ИЗ-ЗА ОСОБЕННОСТЕЙ ИНДИКАТОРА
);

return(ao_sell);



}//КОНЕЦ ПОЛУЧЕНИЯ ДАННЫХ ПО АО СЕЛЛ------------------------------------------------------------------------------------------+

If this function is in the EA file below the tick and the timer, the variables that are declared as externs are clearly visible in this function. But if I completely copy and paste this function into a include file, the external variables are not visible in the function.

The question is, what should I do to make external variables be visible in the functions in the include file, as well as these variables are visible in the EA functions, which I write below the timer?

 
DanilaMactep:

Good afternoon, everyone. Continuing to saw the Grail MachineJ. I have to redo the code with a focus on using functions, because I'm sick of scrolling through a ton of code. I want to move the functions to separate include files. I have created function for getting signal by ao indicator in EA's file for trial and it works fine.

My robot even opens trades. But if I create a plugin file SIGNALS_INDIKATOR. I connect it in my Expert Advisor like this.


I also write my function for getting signals by this type of attachment, but this function doesn't show my external variables which I have easily passed to the EA itself. The function of getting indicator's value in my EA is like this.

If this function is in the EA file below the tick and the timer, the variables that are declared as externs are clearly visible in this function. But if I completely copy and paste this function into a include file, the external variables are not visible in the function.

The question is, what should I do to make external variables be visible in the functions in the include file, as well as these variables are visible in the EA functions, which I write below the timer?

extern variables - what are they?
 
MakarFX:
external variables - what are they?

I will insert a piece of code with them-


//+------------------------------------------------------------------+
//|                                           TREND+DIVERGENCE_V_1.0 |
//|                                                    ДАНЯ ГАГАРКИН |
//|                                     https://vk.com/danila_mastep |
//+------------------------------------------------------------------+
#property copyright "ДАНЯ ГАГАРКИН"
#property link      "https://vk.com/danila_mastep"
#property version   "1.00"
#property strict
//НАЧАЛО ВХОДНЫХ ПЕРЕМЕННЫХ И ГЛОБАЛЬНЫХ ПЕРЕМЕННЫХ------------------------------------------------------------------------------------------+
int intBars;// ПЕРЕМЕННАЯ ДЛЯ ОПЕРДЕЛЕНИЯ КОЛИЧЕСТВА БАРОВ, ЧТОБЫ ОПРЕДЕЛИТЬ ПОЯВЛЕНИЕ НОВОГО



#include <TREND+DIVERGENCE\SIGNALS_INDIKATOR.mqh> 



enum enumCoincidence
  {
   enCoinAccurate=1,    // Точный
   enCoinApproximate=0, // Приближенный
  };
  enum enumYN
  {
   enYes=1, // Да
   enNo=0,  // Нет
  };
  
  enum enumSL //ПЕРЕЧИСЛЕНИЕ ДЛЯ СТОП ЛОССА
  {
   en_fiks=1, // ФИКСИРОВАННЫЙ В ПУНКТАХ
   en_po_atr=0,  // ПО АТР
  };
  // ПЕРЕЧИСЛЕНИЕ ДЛЯ ВКЛЮЧЕНИЯ ПЕРВОГО ЭКРАНА
  
   enum enum_screen1 //ПЕРЕЧИСЛЕНИЕ ДЛЯ ПЕРВОГО ЭКРАНА
  {
   en_on_screen1=1, //  1 ЭКРАН ON
   en_off_screen1=0,  //  1 ЭКРАН OFF
  };
  //ЕНУМ 2-ГО ЭКРАНА
  
   enum enum_screen2 //ПЕРЕЧИСЛЕНИЕ ДЛЯ ВТОРОГО ЭКРАНА
  {
   en_on_screen2=1,    //  2 ЭКРАН ON
   en_off_screen2=0,  // 2 ЭКРАН OFF
  };
  
    enum enum_use_filter //ПЕРЕЧИСЛЕНИЕ ДЛЯ ОТКРЫТИЯ ОТОЛЖАК С ФИЛЬТРОМ ИЛИ БЕЗ
  {
   en_bez_filtra=1,    // БЕЗ ЦЕНОВОГО ФИЛЬТРА
   en_c_filbtpom=0,  // С ЦЕНОВЫМ ФИЛЬТРОМ
  };
  
  //-- ПЕРЕЧИСЛЕНИЕ ДЛЯ ТИПА ОРДЕРОВ
  
  enum enum_tip_orderov
  {
   en_otlojki=1,    // ОТЛОЖЕННЫЕ
   en_rbIno4nbIe=0, // РЫНОЧНЫЕ
  };
  
  //--- ПЕЕРЧИСЛЕНИЕ ДЛЯ ВКЛЮЧЕНИЯ ТРАЛА
      enum enum_use_tral 
  {
   en_on_tral=1,    // С ТРАЛОМ
   en_off_tral=0,  // БЕЗ ТРАЛА
  };
  
  
  enum enumModeLINE
  {
   enMdMain=MODE_MAIN,  // Main
   enMdSign=MODE_SIGNAL,// Signal
  };
  enum enumSignalsMode
  {
   enBuy=0,             // Только Buy
   enSell=1,            // Только Sell
   enBoth=2,            // Buy и Sell
   
  };
  
  extern string  Params = "-- ПАРАМЕТРЫ ОТКРЫТИЯ СДЕЛКИ --";//======================================
  
  extern int slippages= 5; // ПРОСКАЛЬЗЫВАНИЕ
  extern int MaxRisk=1;//  % УБЫТКА ПРИ SL
  extern int razmer_fikc_sl= 500;// ФИКСИРОВАННЫЙ SL П/П?
  extern enum_screen1 flag_screen1= en_on_screen1; // ВКЛ-ВЫКЛ 1 ЭКРАН
  extern enum_screen2 flag_screen2= en_on_screen2; // ВКЛ-ВЫКЛ 2 ЭКРАН
  extern enum_tip_orderov kakie_ordera= en_rbIno4nbIe;// ОРДЕРА ОТКРЫТИЯ?

I have highlighted the external variables in yellow. These variables are displayed when the EA is attached to the chart in the input parameters tab

 
DanilaMactep:

I will insert a piece of code with them-


I have highlighted the external variables in yellow. These variables are displayed when the EA is attached to the chart in the input parameters tab

Now they use "input" instead of "extern".

You also need to move your "extern variables" to the SIGNALS_INDIKATOR.mqh library

 
DanilaMactep:

I will insert a piece of code with them-

The global variables in the EA body are only visible to the EA and not to the plugins,

but global variables in the body of the plugin are visible everywhere.