MQL4 - automated forex trading   /  

Forum

who have other opinion?

Back to topics list To post a new topic, please log in or register

avatar
1515
DxdCn 2009.06.28 12:43 

In DLL,

MT4_EXPFUNC char*__stdcall GetState(int& st,char* which,int& prd)

in such function, MT dead if let st= 123;


MT4_EXPFUNC char*__stdcall GetState(int* st,char* which,int* prd)

in such function, MT no dead.

Both do not change parameters st, which, prd.

only can return soththing with return(.....);

only use array to return multi variables.

This is conclusion !!!

who have other opinion?

article

Interview with Michael Bullock (Zonker)

Constantly plowing back all the profit and scaling up the position is pure suicide trading on a real account. But that is not relevant, this is a competition, over 250 competitors, and only three walk away with anything. You do whatever it takes to maximize your chances to be in that Top Three. I'm not sure you can talk about risk in the context of the competition, risk implies you might lose something, but here there is only a chance to gain for those who beat the odds.


avatar
612
jjc 2009.06.28 20:54 

DxdCn wrote >>

[...] only use array to return multi variables.

This is conclusion !!!

who have other opinion?

AFAIK you're correct that MT4 crashes/doesn't work if you try passing it a non-array variable by reference, and then set the value of that variable in a DLL using a pointer. You have to use arrays instead.


For example, with the following DLL...


extern "C" int WINAPI TestDll(int * p)

{

*p *= 2;

return *p;

}


... the following MQL script causes a fatal crash (in build 220):


#import "TestDll.dll"

int TestDll(int & Param);

#import


int start()

{

int TestVar = 2;

int Result = TestDll(TestVar);

MessageBox("Result: " + Result + "\r\nValue of TestVar: " + TestVar);

}


However, the same DLL works fine if you declare the MQL stuff as follows, turning TestVar into a 1-item array rather than a plain integer:


#import "TestDll.dll"

int TestDll(int & Param[]); // The parameter is now an array - see below

#import


int start()

{

int TestVar[1] = {2}; // Declare TestVar as an array with 1 slot, and put the value 2 into it

int Result = TestDll(TestVar);

MessageBox("Result: " + Result + "\r\nValue of TestVar: " + TestVar[0]);

}

Back to topics list  

To add comments, please log in or register