You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I made a DLL in Delphi, I call it from MT4. Everything works except simple parameters passed by reference. In Delphi, declared as follows:
procedure Test2(var i: integer); stdcall;
begin
if addr(i) = nil then ShowMessage('What the hell?');
end;
stop to call it as
#import "DLL1.dll"
void Test2(int& i);
I call
int init() {
int x = 5;
Test2(x);
return(x);
}
when called, a reference to the variable integer should be in the stack, but null is there
so how to pass an int parameter by reference?
When passing arrays, the array value is passed by reference
using
MetaEditor 4.00 build 183
MetaTrader 4.00 build 186
one more question: if I pass a string as reference, what is the size of the string buffer?
one more question:
If I pass a string as function result, where should the memory area for the string be allocated? Should I pass a pointer to a global variable in the DLL? In this case, may I be sure that the DLL will not be called from different threads simultaneously in any mode of metatrader?
Thanks in advance
at the beginning of the day set two pending orders
Once one (any) triggered - the second is removed
Five minutes before the close of the bar (say a daily) to close the triggered (if it was not closed by SL or TP)
If no pending order triggered, five minutes before closing the bar delete them both
Thank you very much
2) If I pass the string as a function result, where should the memory area for the string be allocated? Should I pass a pointer to a global variable in the DLL? In this case, I can be sure that the DLL will not be called from different threads simultaneously in any mode of the metatrader?
Thanks in advance
When one (any) triggered - the second is deleted
Five minutes before the close of the bar (say a daily) to close the triggered (if it was not closed by SL or TP)
If no pending order triggered, five minutes before closing the bar delete them both
Thanks in advance
You set pending orders at the right time (that's easy). And you start to check orders. As soon as a Buy or Sell order appears, you work through removing the pending order (even easier). And then, at the right time, work to close all orders (this is easy).
в начале дня устанавливаем два отложенных ордера
После того как один(любой) сработал - второй удаляется
За пять минут до закрытия бара(допустим дневного) закрыть сработавший (если он не был закрыт по SL или TP)
Если ни один отложенный ордер не соработал то за пять минут до закрытия бара удаляем их обоих
Заранее спасибо
This is how you implement it, you put pending orders at the right time (it's easy). And then you start to check the orders. As soon as a Buy or Sell order appears, you work through removing the pending order (this is even easier). And then, at the right time, work to close all orders (it is very easy).
I asked for a working code (maybe someone has implemented it).
All I did was not working ... The odrerdelete process is somehow confusing.
Another question: sometimes the price freezes (no ticks) for some minutes, i.e., we cannot close an order as the int start() body is not executed, though ticks are received for other symbols, is it possible to pass the Curetime value from any symbol with ticks?
To put it simply, the Curetime value should practically not freeze
And what does this code fragment do?
Deletes both pending orders that have not triggered yet