extern double Lots = 1;
extern double TP = 100;
extern int TradeType = 0; // 0 to follow the trend, 1 to force buy, 2 to force sell
extern int leverage = 5;
extern double MaximumLossinMoney = 1000;
extern int MagicNumber = 250346;
extern bool UseAlerts = false;
//+-------------+
//| Custom init |
//|-------------+
int init()
{
}
//+----------------+
//| Custom DE-init |
//+----------------+
int deinit()
{
}
void sendEmail()
{
if (UseAlerts==true) SendMail("YTF Alert", "New order has been added "+OrdersTotal()+" Balance = " +AccountBalance() + " Equity = "+AccountEquity() +" Current Price: " + Close[0]);
return;
}
//+------------------------------------------------------------------------+
//| Closes everything
//+------------------------------------------------------------------------+
void CloseAll()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderType() == OP_BUY && OrderMagicNumber()== MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
if ( OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
if (UseAlerts) PlaySound("alert.wav");
}
return;
}
void CloseAllBuy()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderType() == OP_BUY && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5, Red );
if (UseAlerts) PlaySound("alert.wav");
}
return;
}
void CloseAllSell()
{
for(int i=OrdersTotal()-1;i>=0;i--)
{
OrderSelect(i, SELECT_BY_POS);
bool result = false;
if ( OrderType() == OP_SELL && OrderMagicNumber()==MagicNumber) result = OrderClose( OrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5, Red );
if (UseAlerts) PlaySound("alert.wav");
}
return;
}
//+------------------------------------------------------------------------+
//| cancels all orders that are in profit
//+------------------------------------------------------------------------+
//+------------------------------------------------------------------------+
//| cancels all pending orders
//+------------------------------------------------------------------------+
//+-----------+
//| Main |
//+-----------+
int start()
{
int OrdersBUY, ticket;
int OrdersSELL;
double BuyLots, SellLots, BuyProfit, SellProfit;
//+------------------------------------------------------------------+
// Determine last order price |
//-------------------------------------------------------------------+