Errors, bugs, questions - page 2243

 
Vitaly Murlenko:

The code in mql4 indicator stopped working. how can i fix it?

Editor says 'ObjectSetInteger' - no one of the overloads can be applied to the function call

It's been working for years and then suddenly stopped. It's a shame, though.


else{// Иначе стрелка создана. Задаём её свойства
 ObjectSetInteger(ChartID(),Open_name,OBJPROP_ARROWCODE,OpenArrowCode);//код стрелки 232 // или 0 вместо ChartID() для текущего графика 
 ObjectSet(Open_name,OBJPROP_COLOR,ObjColor);//цвет стрелки
}

But why did you mix up two styles? If you use the first line to specify the arrow code, then use the second line in the same style:

ObjectSetInteger(0,Open_name,OBJPROP_COLOR,ObjColor); //цвет стрелки
 

Tried to upload a new version of the indicator to the market. The test ended with errors. Error report as on the picture in the appendix with the following content:

test on EURUSD,H1 (netting) test on XAUUSD,D1 (netting) test on GBPUSD,M30 (netting) test on EURUSD,M1 (netting) 2016.05.31 21:45:00 Access violation at 0x00007FF7FD1CA04B read to 0xFFFFFFFFFFFFFFFFFF 2016.05.31 21:45:00 00 00007FF7FD1CA010 4885D2 test rdx, rdx 2016.05.31 21:45:00 00 00007FF7FD1CA013 747B jz 0x7ff7fd1ca090 2016.05.31 21:45:00 2016.05.31 21:45:00 00 00007FF7FD1CA015 53 push rbx 2016.05.31 21:45:00 00 00007FF7FD1CA016 4883EC20 sub rsp, 0x20 2016.05.31 21:45:00 00 00007FF7FD1CA01A 48897C2430 mov [rsp+0x30], rdi 2016.05.3131 21:45:00 00 00007FF7FD1CA01F 488BD9 mov rbx, rcx 2016.05.31 21:45:00 00 00007FF7FD1CA022 488B7AF8 mov rdi, [rdx-0x8] 2016.05.31 21:45:00 00 00007FF7FD1CA026 4881FF00004000 cmp rdi, 0x400000 2016.05.31 21:45:00 00 00007FF7FD1CA02D 730B jae 0x7ff7fd1ca03a 2016.05.31 21:45:00 00 00007FF7FD1CA02F 4883E980 sub rcx, 0x80 2016.05.31 21:45:00 00 00007FF7FD1CA033 E88852CAFF call 0x7ff7fce6f2c0 ; #2504 (metatester64.exe) 2016.05.31 21:45:00 00 00007FF7FD1CA038 EB37 jmp 0x7ff7fd1ca071 2016.05.31 21:45:00 2016.05.31 21:45:00 00 00007FF7FD1CA03A 488D4AE8 lea rcx, [rdx-0x18] 2016.05.31 21:45:00 00 00007FF7FD1CA03E 488B52E8 mov rdx, [rdx-0x18] 2016.05.31 21:45:00 00 00007FF7FD1CA042 4885D2 test rdx, rdx 2016.05.3131 21:45:00 00 00007FF7FD1CA045 7408 jz 0x7ff7fd1ca04f 2016.05.31 21:45:00 2016.05.31 21:45:00 00 00007FF7FD1CA047 488B4108 mov rax, [rcx+0x8]
Maybe the problem is in the tester?
Files:
 
Artyom Trishkin:

Just why did you mix the two styles? If you use the first line to set the arrow code, then use the second line in the same style:

Thank you, that helped.

2 styles? I didn't know about the styles. It's just that previously you could only do this section that way. There has been a change. I've been programming in MQL4 for more than 10 years. And now the developers have changed the language and many of my codes do not work anymore. I'm very disappointed. The changes were not for the better. It means that I have to redo a huge amount of codes. Even though they are old, they were a lot of use.

 
Gennadiy Stanilevych:

Tried to upload a new version of the indicator to the market. The test ended with errors. Error report as shown in the picture in the appendix with the following content:

Maybe the problem is in the tester?

Please create a request to servicedesk, we'll figure it out


UPD: Found your request.
 
Artyom Trishkin:

Frees the buffer of any dynamic array and sets the size of the zero dimension to 0.

When scripts and indicators are written, the need to use the ArrayFree() function may occur rarely, as all used memory is immediately released, and in custom indicators the main work with arrays is represented by access to indicator buffers, the sizes of which are automatically managed by the executive subsystem of the terminal.

If you need to manage memory in complex dynamic conditions in your program, the ArrayFree() function will allow you to explicitly and immediately free the memory occupied by a dynamic array that is not needed anymore.

You see? Unnecessary.

Naturally, once memory is freed from it, and then you allocate it again by assigning a size to the array, nobody can guarantee its contents.

Use array initialization: ArrayInitialize()

What do you mean, no one guarantees the contents? If the memory was freed, it's gone, so how do you get rubbish in it? Or does clearing the memory imply giving permission for that memory to be used by another part of the program, not actually clearing it at all?

 
Aleksey Vyazmikin:

What do you mean no one guarantees the contents? If the memory has been cleared, it is no longer there, so how does it get rubbish in it? Or does clearing memory imply giving permission for that memory to be used by another part of the program, not actually clearing it at all?

ArrayResize doesn't clean up memory, which is why it contains rubbish, from the previous "consumer".

This is done for speed, because after memory is allocated to an array, in 99.99(9)% of cases, the user will "fill" it with his data.


 
Vitaly Murlenko:

Thank you, that helped.

Two styles? I didn't know about the styles. It's just that previously you could only do this section that way. There has been a change. I've been programming in MQL4 for more than 10 years. And now the developers have changed the language and many of my codes do not work anymore. I'm very disappointed. The changes were not for the better. It means that I have to redo a huge amount of codes. They may be old, but they were a whole lot more useful.

Isn't it how the arrow code was set before mql4 ObjectSetXXX-functions were introduced?

ObjectSet(Open_name,OBJPROP_ARROWCODE,OpenArrowCode);

I've also been writing in mql for about 10 years (maybe more - how time flies...) - I'm starting to forget strictly Quaternary functions - I write multiplatform code when possible.

 
Ilyas:

ArrayResize doesn't clear the memory, that's why it contains rubbish from the previous "consumer".

This is done for speed, because after memory allocation to an array, in 99.99(9)% of cases, the user will "fill" it with his data.


Then why are the numerical values "rubbish" constants, even after restarting the terminal?

Personally, I got stuck with simple summing up the contents of cells in another array, and I've been puzzling over the problem for a long time.

      for(int i=1;i<StrokTotal; i++)
        {
         for(int s=3;s<56+1; s++)
           {               
            SummArrA[s]=SummArrA[s]+ArrTest[i,s];
           }
        }     
 
Aleksey Vyazmikin:

Then why are the numeric values "rubbish" constants, even after restarting the terminal?

Personally, I got burned on a simple summation of the contents of cells in another array, and wondered for a long time what the problem was

It doesn't matter what kind of data is contained in the uninitialised array, at any moment, the data can change, no one guarantees its value.
That's why using uninitialized variables (read memory) sometimes leads to situations where it takes a long time to find the cause:

  1. Works on one computer, not on the other
  2. Works in the terminal, not in the tester
  3. Terminal/OS updated and program behaves differently
  4. Added Print stopped working.
  5. etc.

I can only give some advice.
You should get into the habit of always initializing data, so that in the future you don't waste a lot of time searching for errors related to the lack of initialization.

Автоматическое обновление - Для продвинутых пользователей - MetaTrader 5
Автоматическое обновление - Для продвинутых пользователей - MetaTrader 5
  • www.metatrader5.com
В платформу встроена система автоматического обновления. Она позволяет своевременно получать и устанавливать новые версии программы. Эту систему отключить нельзя. Порядок обновления При подключении к торговому серверу происходит проверка наличия обновлений платформы. Если найдено обновление какого-либо из компонентов торговой платформы...
 
Aleksey Vyazmikin:

What do you mean no one guarantees the contents? If the memory has been cleared, it is no longer there, so how does it get rubbish in it? Or does clearing memory imply giving permission for that memory to be used by another part of the program, not actually clearing it at all?

What do you mean "no"? You don't remove the memory stick from the motherboard slot. And if the memory is present and it is freed (not initialized with a value, but freed), then it is being used for other program needs.