[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 548

 
artmedia70 писал(а) >>
What is error 4051 and how to catch it?


https://docs.mql4.com/ru/constants/errors

ERR_INVALID_FUNCTION_PARAMVALUE 4051 Invalid value of function parameter

 
artmedia70 >>:
А кто сказал, что именно тот кусочек работает неправильно? Если б я выложил весь код - места бы не хватило...
Сначала вызываете на общение, потом в кусты... :)


No. I suggested that you take apart a piece of code that doesn't work. Take it apart in every detail. Instead of that you laid out the whole code. :)

I'm not going to hide in any bushes. >> I quote:

>>Let's take apart line by line a piece of your code that doesn't work correctly...

>> shall we?

Here are my words. Instead of a piece that doesn't work you've put out a bunch of incomprehensible stuff - some set of functions. That's what I don't like.

 

Generally speaking, in order to find an error, you need to block out some parts of the code. For example, the code consists of the following blocks:

- Block checking for trading signals

- Block opening/closing/reversing orders

- Block maintaining open positions.

We block the last two blocks using the multi-line comment /**/, run the EA and use the print or alert to check the values of the key variables - just to make sure that this block works correctly. If we come across an error, fix it. Then unlock the next code block and repeat the procedure. And so on until the whole code is debugged. The other way would be more tedious.

 
drknn >>:

Вообще, чтоб найти ошибку, нужно заблокировать некоторые участки кода. Например, код состоит из следующих блоков:

- Блок проверки наличия торгового сигнала

- Блок открытия/закрытия/переворота ордеров

- Блок сопровождения открытых позиций.

Блокируем при помощи многострочного комментария /**/ два последних блока, запускаем советника и с помощью принта или алерта снимаем значения ключевых переменных - просто убеждаемся, что этот блок работает корректно. Если натыкаемся на ошибку, то исправляем её. Затем снимаем блокировку со следующего блока кода и повторяем процедуру. И так далее до тех пор, пока весь код ни окажется отлажен. Другой путь будет более утомителен.

Yes, thank you, I'm already familiar with that... I'm a little lacking in knowledge. And I posted all the code simply because I don't know which part of it doesn't work. It doesn't necessarily have to be the one originally posted. Thank you for your participation... :)
 
Could you please advise how to add an indicator in an Expert Advisor to take data from cf h4?
#property copyright "Krokus"
#property link      ""
//----
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Red
//----
extern int       N=20; // период канала 
//---- buffers
double ExtMapBuffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit;
   double upPrice,downPrice;
//---- 
   if (counted_bars==0) limit=Bars-N;
   if (counted_bars>=0) limit=Bars-counted_bars;
   limit--;
   for(int i=limit;i>=0;i--)
     {
      upPrice=High[iHighest(Symbol(),0,MODE_HIGH,N,i)];//максимум за N баров 
      downPrice=Low[iLowest(Symbol(),0,MODE_LOW,N,i)]; //минимум за N баров 
      ExtMapBuffer1[i]=(upPrice-downPrice)/Point;

     }
//---- 
   return(0);
  }
//+------------------------------------------------------------------+
 
into the examiner's code, not into the call
 
Andrei01 >>:
Скажите, должны ли рисоваться графические объекты советником в тестере не в ценовом окне, а в отдельном? Почему-то это не работает при замене нуля на единицу при создании объекта.

Create an empty iCustom indicator with a separate window and call it from the EA,

If you do not have a window, then you give a command for drawing, and there is no need to do it.

The only thing to pay attention to is the scale,

The easiest way is to set two buffers to the background colour,

In one window you assign max and in the other min, it's convenient and you can adjust it from the external parameter of the indicator.

 
sllawa3 >>:
подскажите пожалуйста как вписать индюк в эксперт чтоб снимал данные с тф н4 ???
for(int i=limit;i>=0;i--)
     {
      int ii=iBarShift(Symbol(), 240, i);//Symbol() или NULL

      upPrice=iHigh( NULL, 240,  iHighest(NULL, 240 ,MODE_HIGH,N, ii) );//максимум за N баров 
      downPrice=iLow( NULL, 240,  iLowest(NULL, 240 ,MODE_LOW, N, ii) ); //минимум за N баров 

      ExtMapBuffer1[i]=(upPrice-downPrice)/Point;

     }
to calculate the right TF (H4) independently of the chart, something like this
 
this will not work... The limit is not prescribed and how to prescribe it ?
int    counted_bars=IndicatorCounted();
тоже в эксперте не потянет
 
Barrel!!! Open positions are each trawled, while closing on "other people's" TP and SL... Consequently, it's a mess... How to win?
Reason: