[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 30

 

Apologies for being off topic. Please advise if anyone knows an EA that would close

I would like to ask you if you know an Expert Advisor which will close all positions in your account once the total TP and SL have been reached. I am grateful in advance.

 
Chatlanen >> :

Apologies for being off topic. Please advise if anyone knows an EA that would close

I would like to ask you if you know an Expert Advisor which will close all positions in your account once the total TP and SL have been reached. Thanks in advance.

Once all of the take and loss has been reached, the positions will all be closed anyway. Please state the question more precisely

 

I have a problem I press the compile button and get 2 errors:

1. In the line:

int Fun_Error(int Error) // Error handling function

'(' - function definition unexpected C:\Users\Paul\Desktop\Heiniken M.mq4 (209, 14)
2. In the line:

default: Alert('An unidentified error has occurred', Error); // Other options

'Error' - variable not defined C:\Users\Pàâåë\Desktop\Heiniken M.mq4 (242, 53)

I have a question - is Fun_Error() a standard function or it needs to be written (I took this part of code from another EA)?

The 2nd error follows from the first one, I cannot understand what may be the problem((.

 

change the variable name to err for example

 
JavaDev >> :

change the variable name to e.g. err

now it can't find err(

 
Show the function code
 
  //-----------------------------------------------------------10-+
int Fun_Error(int Err) // Error handling fie
{
switch(Err)
{ // Errors that can be overcome.
case 4: Alert("The trade server is busy. Try again...");
Sleep(3000); // Simple solution.
return(1); // Exit function.
case 135:Alert("Price changed. Try again...");
RefreshRates(); // Refresh data.
return(1); // Exit from the function.
case 136:Alert("No price. Waiting for a new tick...");
while(RefreshRates()==false) // Till a new tick
Sleep(1); // Delay in the loop
return(1); // Exit from the function
case 137:Alert("Broker is busy. Try again...");
Sleep(3000); // Simple solution.
return(1); // Exit from the function.
case 146:Alert("The trading subsystem is busy. Try again...");
Sleep(500); // Simple decision
return(1); // Exit from the function
// Critical errors
case 2: Alert("General error;)
return(0); // Exit from the function.
case 5: Alert("Older version of the terminal.");
Work=false; // No longer work
return(0); // Exit from the function
case 64: Alert("Account blocked.");
Work=false; // No longer work
return(0); // Exit from the function
case 133:Alert("Trading prohibited.");
return(0); // Exit from the function
case 134:Alert("Not enough money to execute the transaction.");
return(0); // Exit from the function
default: Alert("An unidentified error has occurred", Err); // Other options
return(0); // Exit from the function
}
}
//-------------------------------------------------------------- 11 --
int New_Stop(int Parametr) // Check stop-prick.
{
int Min_Dist=MarketInfo(Symb,MODE_STOPLEVEL);// Min. distance
if (Parametr<Min_Dist) // If less than allowed.
{
Parametr=Min_Dist; // Set tolerance.
Alert("Stop distance increased;)
}
return(Parametr); // Return value.
}
//-------------------------------------------------------------- 12 --
 
Is there a handy compiler somewhere that counts birds? It's very hard to count errors in code((
 

I wanted my Expert Advisor to send a small report to the mail at 8 and 11:30 a.m., like this

if(Hour()==8 && Time[z]!= LastTimeHS)
SendMail(""," Balanse "+AccountBalance()+" "+AccountCurrency()+
" \n Total Orders " +OrdersHistoryTotal()+
" \n Open Orders "+OrdersTotal()+
" \n Orders Profit "+AccountProfit()+
" \n Equity " +AccountEquity()+" "+AccountCurrency());
LastTimeHS = Time[z];
return;

if(Hour()==11 && Minute()==30 && Time[z]== LastTimeHS)
SendMail(""," Balanse "+AccountBalance()+" "+AccountCurrency()+
" \n Total Orders " +OrdersHistoryTotal()+
" \n Open Orders "+OrdersTotal()+
" \n Orders Profit "+AccountProfit()+
" \n Equity " +AccountEquity()+" "+AccountCurrency());
LastTimeHS = 0;
return;


This code cuts off Expert Advisor for some reason (I put it in the wrong place, at the beginning) and sends e-mail every 5 minutes (seems to be on every new candle). Please help me to understand what I messed up, I can't understand what's wrong...

 
Reshetov >> :

Once all the take and loss has been reached, all the positions will be closed anyway. You might want to be a little more specific.

Let's say I have 5 different positions open (they have no TP and SL), once the total profit will be +$100 or -$100, I need to close all orders, regardless

whether they are on the plus side or the minus side

Reason: