Errors, bugs, questions - page 379

 
Graff:

Does it make sense to

replace rates_total with BarsCalculated(ich)?

I don't think so. It's more like a service stub to make sure the buffer is ready...

Besides, Copy will return as much data as calculated, not the requested size.


And what city are you from, if not a secret?

not in Dnepr.
 
sergeev:

By the way, are you sure you don't need to call any additional functions?

The library has both Refresh and BufferResize. It seems to me that they are necessary for normal functioning.


And where is it written that they should be?

I tried different variants.

ichi.Refresh(true);
ichi.Refresh(false);
ichi.RefreshCurrent(true);
ichi.RefreshCurrent(false);

I got no effect.

 

Continued....

The iIchimoku indicator is experiencing a glitch. My indicator just draws arrows depending on if(tenkan[i]>kijun[i]). As you can see in the screenshot the arrows are not drawn correctly

The full code is in the file Ich_1_f.mq5

However, if you calculate them manually, everything is displayed correctly

Full code in the file Ich_1_ok.mq5

Files:
Ich_1_f.mq5  6 kb
Ich_1_ok.mq5  6 kb
 

Write the dll :

#define _DLLAPI extern "C" __declspec(dllexport)
//+------------------------------------------------------------------+
//| адрес переменной double                                          |
//+------------------------------------------------------------------+
_DLLAPI int __stdcall
GetPtrVar(double a){return((int)(&a));}
//+------------------------------------------------------------------+
//| значение переменной double по адресу                             |
//+------------------------------------------------------------------+
_DLLAPI double __stdcall
GetValuePtr(int pointer){return(*(double*)pointer);}

plug it in :

#import "Projeckt1.dll"
int      GetPtrVar(double a);
double   GetValuePtr(int pointer);
#import

call :

void OnStart()
  {   
   double var=153.25; 
   Print("вложенный вызов = ",GetValuePtr(GetPtrVar(var)));
   int pointer=GetPtrVar(var);   
   Print("вызов с сохранением адреса = ",GetValuePtr(pointer));
  }

we get this:

2011.05.01 18:09:12     Черновик 31 (EURUSD,H1) вызов с сохранением адреса = 5.560304580319136 e-287
2011.05.01 18:09:12     Черновик 31 (EURUSD,H1) вложенный вызов = 153.25

although both lines should return the same value 153.25.

Why?

 
Urain:

Why?
Is this in the 32 or 64 bit version?
 
Renat:
Is this in the 32 or 64 bit version?

32
 

It is very simple - in the GetPtrVar(double a) function you take the address of a copy of the variable in the stack and then try to read the littered piece of stack memory.

The first time, because of a close call of GetValuePtr we managed to read from the uncontaminated stack, while subsequent function calls damaged the stack irrevocably.

There is no error.

Документация по MQL5: Основы языка / Функции / Вызов функции
Документация по MQL5: Основы языка / Функции / Вызов функции
  • www.mql5.com
Основы языка / Функции / Вызов функции - Документация по MQL5
 
Renat:

It's very simple - in the GetPtrVar(double a) function take the address of a copy of the variable in the stack, and then try to read the littered piece of stack memory.

Yes, exactly, I felt that I needed to dig there somewhere.

you have to write in the dll

GetPtrVar(double &a){return((int)(&a));}
 
Renat:

It is very simple - in the GetPtrVar(double a) function you take the address of a copy of the variable in the stack and then try to read the littered piece of stack memory.

The first time, because of a close call of GetValuePtr we managed to read from the uncontaminated stack, while subsequent function calls damaged the stack irrevocably.

There is no error.

I noticed it too. I think this is the right way to do it:

#define _DLLAPI extern "C" __declspec(dllexport)
//+------------------------------------------------------------------+
//| адрес переменной double                                          |
//+------------------------------------------------------------------+
_DLLAPI int __stdcall
GetPtrVar(double & a){return((int)(&a));}
//+------------------------------------------------------------------+
//| значение переменной double по адресу                             |
//+------------------------------------------------------------------+
_DLLAPI double __stdcall
GetValuePtr(int pointer){return(*(double*)pointer);}

plugging :

#import "Projeckt1.dll"
int      GetPtrVar(double & a);
double   GetValuePtr(int pointer);
#import
 
In the 439 build of Metatrader5, a history quality indicator has been added. When I'm testing on M1 and H4 on opening prices and on all ticks, the quality is 51%... Why and how to increase it? The source of the quotes is alpari demo.
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы индикаторов / Ценовые константы - Документация по MQL5
Reason: