How to code? - page 78

 

I got it to work now.

 
hedge4x:
This line while(!IsAllClosed) {CloseAllTrades(); return;}

in the main start will close all open positions if MT goes down

and I start it back up. Is there a way to put this line

in the closealltrades function so it won't close all open positions

after MT4 restart?

thanks.

Yes, sorry you can define the bool at start time like this :

bool IsAllClosed = true ; //Global variable[/PHP]

Then it becomes even better to define a extern variable, so you can keep the control :[PHP]extern bool CloseAll = false ; //Global variable

void CloseAllTrades()

{

int cnt;

CloseAll = false;

for(cnt=OrdersTotal()-1;cnt>=0;cnt--)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if (OrderMagicNumber()==GetMagicNumber())

CloseAll = CloseAll || !OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), MarketInfo(OrderSymbol(), MODE_SPREAD), Yellow);

}

}

void start()

{

while(CloseAll) {CloseAllTrades(); return;}

...

The main advantage of this method is that the EA try to close each postion at each tick until all are closed.

 

help needed with my semi profetable first EA

Hi All...

i made an EA by the great expert advisor bulder web site and i test it and found it profitble for the last year but i think that can be enhanced ...

so if any one can help to improve that EA ?

detaled about EA..

the EA pased on two indecators one of them is mine and the other is can found on bublic fourms " zero lag macd "

now the expert is working all the time enter buy then close and reverse to sell and so on ...

i need to make it work only in spesfic times, add a money managemint and the last thing i need to delay the excute of buy or sell with the next "1 minute" candel but the EA work on the 1H candel in fact ...

so hope to find how can help in that

Thank you All

best regards

Tamer

Files:
 

how to refer to the filename I'm running?

Hi,

I want to know how can I refer to a filename that I am running.

For example if I run a script called supertrader.mq4 and I want to open a logfile called supertrader_logfile from the script supertrader.

Is there a variable that holds the name of the file I am running?

Thanks.

 
star90:
Hi,

I want to know how can I refer to a filename that I am running.

For example if I run a script called supertrader.mq4 and I want to open a logfile called supertrader_logfile from the script supertrader.

Is there a variable that holds the name of the file I am running?

Thanks.

Maybe by adding void Print( ...) to the script.

void Print( ...) Prints a message to the experts log.

 

To adria

Did you see my PM?

Big Be

 

Wolf Wave. I need your help

Dear Codersguru,

I am not a programmer and in my trial and error style, the wolf wave I tried to improve is giving the signal " the second parameter, ObjectTextSetFunction must be a string.

Please help me to rectify.

Thank you in anticipation.

Files:
wolfwave.rar  3 kb
 

Hi guys I need a bool function that returns true if 5 mins has passed, or 10 mins or whatever. I know how to check for a new bar already but its not often enough.

 
nittany1:
Hi guys I need a bool function that returns true if 5 mins has passed, or 10 mins or whatever. I know how to check for a new bar already but its not often enough.

Maybe

double LastRedraw = 0;

if(TimeLocal() - LastRedraw > 300)

{

Print();

ObjectsRedraw();

Print("ObjectsRedraw Done");

LastRedraw = TimeLocal();

}

 
Linuxser:
Maybe

double LastRedraw = 0;

if(TimeLocal() - LastRedraw > 300)

{

Print();

ObjectsRedraw();

Print("ObjectsRedraw Done");

LastRedraw = TimeLocal();

}

[/code]

Or this:

[CODE]

bool ElapsedTimeCheck(int MyMinutes)

{

static datetime OldTime;

if (OldTime == 0)

OldTime = TimeCurrent() + MyMinutes * 60; // initialised once...

if (TimeCurrent() >= OldTime)

{

OldTime = TimeCurrent() + MyMinutes * 60;

bool cond = true;

}

else cond = false;

return(cond);

}