MQL4 - automated forex trading   /  

Forum

Free margin

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

avatar
8
barry 2006.08.20 05:32 
Free margin is shown in real time in the Terminal/Trade tab. I want to see the lowest value of Free Margin during a week. Is there a way to see the history of Free Margin, eg, for the last week? 
article

Channels. Advanced Models. Wolfe Waves

The article describes rules of marking patterns of Wolfe Waves. You will find here details of constructing and rules of accurate marking, which help to find correct formations of waves quickly and correctly.


avatar
9
cubesteak 2006.08.20 10:24 
I don't think that is kept anywhere, as if you look at the account history, amount of free margin isn't listed.

If you wanted to do it manually, I would keep a simple file that holds the lowest free margin that you've encountered.

So, the flow (in sloppy pseudo-code):


if (indicators say trade)
{
maketrade();
double FreeMargin = AccountFreeMargin();
int handle = FileOpen("mymarginfile.dat",FILE_BIN|FILE_READ);
double LowestMarginSoFar = FileReadDouble(handle, DOUBLE_VALUE);
FileClose(handle);

if (FreeMargin < LowestMarginSoFar)
{
handle = FileOpen("mymarginfile",FILE_BIN|FILE_WRITE);
FileWriteDouble(handle, FreeMargin, DOUBLE_VALUE);
FileClose(handle);
}

}

This way, your file will always hold the lowest value of your margin. You can then reset it weekly manually, or add code to the EA or use a script to reset it "automatically".

Anyway, don't know if that is the smartest way to do it, but it should work. :)

Cheers,
-cubesteak

avatar
8
barry 2006.08.22 04:14 
cubesteak wrote:
I don't think that is kept anywhere, as if you look at the account history, amount of free margin isn't listed.

If you wanted to do it manually, I would keep a simple file that holds the lowest free margin that you've encountered.

So, the flow (in sloppy pseudo-code):


if (indicators say trade)
{
maketrade();
double FreeMargin = AccountFreeMargin();
int handle = FileOpen("mymarginfile.dat",FILE_BIN|FILE_READ);
double LowestMarginSoFar = FileReadDouble(handle, DOUBLE_VALUE);
FileClose(handle);

if (FreeMargin < LowestMarginSoFar)
{
handle = FileOpen("mymarginfile",FILE_BIN|FILE_WRITE);
FileWriteDouble(handle, FreeMargin, DOUBLE_VALUE);
FileClose(handle);
}

}

This way, your file will always hold the lowest value of your margin. You can then reset it weekly manually, or add code to the EA or use a script to reset it "automatically".

Anyway, don't know if that is the smartest way to do it, but it should work. :)

Cheers,
-cubesteak

Thanks cubesteak, I was hoping for a built-in function that doesn't require coding, since my coding ability is limited.  If this is the only way to do it though, and I'm using 2 EA's on the one account, do I insert that code in one of the EA's, and then where do I locate the mymarginfile.dat file? Thanks for your help.
Back to topics list  

To add comments, please log in or register