Questions from Beginners MQL5 MT5 MetaTrader 5 - page 572

 
Boris.45:
Hi, I am writing an EA for MT5. I have written an EA in MT5 which I have wanted to use for automatically searching for the necessary patterns and opening positions manually. I.e. there are no trading functions in the EA. My problem is that I cannot install this EA on a chart. There are no indicator calls in the EA. All indicators are written in program. I compiled it and ran it in the strategy tester. There were no problems. I have just put the EA on the chart and allowed it to trade on the screen, in the settings and in the EA window that pops up. Instead of the smiley face on the chart, the Expert Advisor's icon appears on the price chart and a green circle with a white triangle inside it. I tried this procedure several times and got the same results. I changed periods on the price chart, the message from OnDeinit() appears on the monitor, i.e. one candle is processed in the program and work stops.

I took a look at the logbook:

- One of the attempts to install an EA resulted in a Profile change message;

- In all other attempts the EA is loaded without any problems.

I used to work with Profiles: I increased the number of Profiles, set different charts on each Profile. If there was something wrong there, unfortunately, I don't know it. I do not know what must be broken there for the program to give a message about profile change. Although it is possible that the failure is due to some other reason. It is not clear to me.

For the sake of testing, I have created a new EA (template) today and did not write anything in the OnInit(), OnDeinit(const int reason), OnTick() functions and tried to put this EA on the chart and allow trading.

I got the same situation as before.

Please help me to deal with the situation. Thank you !!!!!!

Let's take it one step at a time. Here is the template:

//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//|                              Copyright © 2016, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2016, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Trade function                                                   |
//+------------------------------------------------------------------+
void OnTrade()
  {
//---
   
  }
//+------------------------------------------------------------------+

Attach it to the chart and a screenshot of the chart in the studio, as well as the entries from the "Journal" and "Advisors" tabs (if they appear there).

Files:
Test.mq5  2 kb
 
I guess there are no professionals here either. pity......
 
Mihail Marchukajtes:
I take it there are no professionals here either. pity......
So reprint the Momentum values from someone else's chart in the tester
 
Artyom Trishkin:
So reprint the Momentum values from someone else's chart in the tester
Print shows what the buffer draws. There is no information. Can anyone give a sensible answer???? Not unintelligible speculation....
 
Mihail Marchukajtes:
Print shows what the buffer draws. There is no information. Can anyone give a sensible answer???? Not some obscure speculation....
So you give zero information. Where's your code? Or is everyone here a psychic or something? Then you should go to the forum of magicians in the tenth degree...
 

Colleagues, can you tell me how to compare candle parameters within a given range?

How to calculate the Maximum or Minimum value, I understand.

Here is the code:

void OnTick()

{

double H = 0;

for ( shift = Search_Period; shift >0; shift--)

{

if (High[shift] > H)

{ H = High[shift]; }

Alert (H);

}

}

But the problem is that it overwrites the value of the variable.

My aim is to find, for example, two or more candlesticks with the same price value of High. In other words, in idea, after each iteration a variable should be created which will store the value, then another one, and so on, until the entire interval is checked. And then they will be able to be compared further.

But I have no idea how to do it ((.

 
Andrey Koldorkin:

Colleagues, can you tell me how to compare candle parameters within a given range?

How to calculate the Maximum or Minimum value, I understand.

Here is the code:

...............


But the problem is that it overwrites the value of the variable.

And my purpose, is to find, for example, two or more candlesticks with the same price value of High. I.e. in idea, after each iteration, a variable should be created which will store the value, then another one, and so on, until the entire interval is checked. And then they will be able to be compared further.

But I have no idea how to do it ((

It looks like this:

//+------------------------------------------------------------------+
//|                                                     TestCopy.mq4 |
//|              Copyright 2016, Artem A. Trishkin, Skype artmedia70 |
//|                       https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, Artem A. Trishkin, Skype artmedia70"
#property link      "https://login.mql5.com/ru/users/artmedia70"
#property version   "1.00"
#property strict
#property script_show_inputs
//--- input parameters
input int Search_Period=100;  // Количество копируемых High
int searchPeriod=(Search_Period<1)?1:Search_Period;
double mass_high[][2];        // массив значений High и их времени
MqlRates array[];             // Массив для копирования Open, High, Low, Close, Time
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
   int copy_bars=(int)fmin(Search_Period,Bars(Symbol(),Period()));
   if(CopyRates(Symbol(),PERIOD_CURRENT,1,copy_bars,array)>0) {
      double H=0;
      int size_h=0;
      for(int i=0; i<copy_bars; i++) {
         if(array[i].high>H) {
            H=array[i].high;
            size_h++;
            ArrayResize(mass_high,size_h);
            mass_high[size_h-1][0]=H;
            mass_high[size_h-1][1]=(int)array[i].time;
            }
         }
      }
   for(int i=0; i<ArrayRange(mass_high,0); i++) {
      printf("Время: %s, High: %.5f",TimeToString((int)mass_high[i][1],TIME_DATE|TIME_MINUTES),mass_high[i][0]);
      }
  }
//+------------------------------------------------------------------+
 
how to write two different advisers into one?
 
Сергей Зырянов:
how do you put two different EAs into one?
What are you interested in? You copy the code from one EA to another, but you need to copy it correctly, if you do not understand how to do it, order it from a freelancer.
 
Artyom Trishkin:

It goes something like this:

I'll try to figure it out. Thank you.

Reason: