Free EA, Buy---Leave -Send Email when done.

 
//+------------------------------------------------------------------+
//| Single Pair Buy leave Email.mq4 |
//| |
//+------------------------------------------------------------------+
#property copyright "o_0"
#property link ""

//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
extern string Email_Header = "Bull # Take profit Executed Please Check EA-";
extern string Email_Body="Profit=$";
extern string Email_Header2 = "StopLoss Executed Please Check EA-";
extern string Email_Body2="(Max Loss Allowed =1% of Account Equity ) Loss = $";
extern int Email_every??_Enter_Millisecs=300000;
extern double lotsize;

extern int Enter_TakeProfit_as_a_Percent=0;
extern int Enter_Max_Loss_as_a_Percent=0;
extern string Dont_Forget="Only Risk what you can afford to loose";


double OldArray[5];




int ordersell=0;

int init()
{int CalcltB=AccountBalance()/2000;


OrderSend(Symbol(),OP_BUY,lotsize,Ask,3,0,0,"",789);
int ordersell=OrderTicket();
OldArray[1]=ordersell;
//----

//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----

//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
double Account_Balance=AccountBalance();
OldArray[2]=Enter_TakeProfit_as_a_Percent;
double x2=OldArray[2]/100;

double x3=OldArray[3]/100;
OldArray[3]=Enter_Max_Loss_as_a_Percent;




OldArray[1]=ordersell;
double sl=AccountBalance()*Enter_Max_Loss_as_a_Percent;
double x=OrderOpenPrice()-sl;



double Close_@_Profit_?=Account_Balance*x2;

double Profit=Account_Balance+Close_@_Profit_?;
double Lossx=Account_Balance*x3;
double Loss=Lossx*(-1);
int Manually_Closed_Open_Orders;

int TotalStoploss;
int total;
int TrueToatal;


Manually_Closed_Open_Orders=0;

TotalStoploss=0;
total=0;
TrueToatal=0;




double Currentat=Account_Balance+ Close_@_Profit_?;
double Eq_Percent= AccountEquity()/Currentat;
int NewEq=Eq_Percent*100;



TrueToatal=OrdersHistoryTotal();
Comment (" TradeOrders Live =",OrdersTotal()," Account History total=",TrueToatal," Equity Target Now =>$",DoubleToStr(Currentat,2)," TakeProfit Amount ("+DoubleToStr(Enter_TakeProfit_as_a_Percent,1)+"% )"+" =$",DoubleToStr(Close_@_Profit_?,2)," Maximum Risk/Stoploss ("+DoubleToStr(Enter_Max_Loss_as_a_Percent,1)+"% )"+" =$"+DoubleToStr(Loss,2)," Good LUck ;)");
int Calclt=Account_Balance/1000;
double lotsize=1;
double Profit_Wanted_in_dollas=Account_Balance*0.02;



if (AccountEquity()<Profit&&OrdersTotal()>0)
{static bool first = true;
static int pre_OrdersTotal = 0;
int _OrdersTotal = TrueToatal;

if ( first )
{
pre_OrdersTotal = _OrdersTotal;
first = false;
return(0);
}


if ( _OrdersTotal > pre_OrdersTotal && OrdersTotal()==0 ||AccountEquity()<=Loss )
{ OrderSend(Symbol(),OP_SELL,lotsize,Bid,3,0,0,"SELL",0,0);
PlaySound("W1.wav");
Alert(Symbol()+ "-The amount of Closed positions increased! There were -# ", pre_OrdersTotal,
", there are now -# ", _OrdersTotal ); }}

if (AccountEquity()>= Profit&& OrdersTotal()==0)

{ SendMail(Email_Header+Symbol(),Email_Body+DoubleToStr(OrderProfit(),2));
Alert(Symbol()+"Mail sending .............Waiting For New Balance $$$..(F7)");

Sleep(Email_every??_Enter_Millisecs);
PlaySound("Apple.wav");}

if (AccountProfit()>Loss && OrdersTotal()==0)

{ SendMail(Email_Header2+Symbol(),Email_Body2+DoubleToStr(OrderProfit(),2));
Alert(Symbol()+"Stoploss :( Mail sending .............Waiting For New Balance $$$..(F7)");
Sleep(Email_every??_Enter_Millisecs);
PlaySound("Apple.wav");}

if (AccountEquity()>= Profit|| AccountProfit()<=Loss)
{

if(OrderSelect(ordersell,SELECT_BY_POS,MODE_TRADES)==true)
{
switch(OrderType())
{

case OP_SELL :OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Violet); break;


}

}
else
Alert(" Warning All orders closed out $$$ Lets Get It. ");}

if (AccountEquity()<=Loss)
{

if(OrderSelect(0,SELECT_BY_POS,MODE_TRADES)==true)
{
switch(OrderType())
{

case OP_SELL :OrderClose(OrderTicket(),OrderLots(),Ask,NULL,Violet); break;

default :Alert("Unknown order type: ",OrderType()," of trade ticket ",OrderTicket());
}

}}



// Memorize the amount of positions
pre_OrdersTotal = _OrdersTotal;



return(0);
//----

//----

}
//+--------------------------------------------------------------
 

You have some questions about coding?

Otherwise will be prefered to post in codebase!

Best regards

 
Either attach or use src
Reason: