#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#include <WinUser32.mqh>
extern bool CloseOrder=TRUE; //Close All Order
extern bool disableexpert=TRUE; //Disable Expert Advisor
extern double EquityTarget=999999; //Equity Take Profit (USD)
extern double EquityStop=0; //Equity Stop Loss (USD)
//+------------------------------------------------------------------+
//| check live trading and dll |
//+------------------------------------------------------------------+
int OnInit()
{
if(!IsTradeAllowed() && !IsDllsAllowed())
{
Alert("Please Allow Live Trading and DLL Import");
return(1);
}
else if(!IsTradeAllowed())
{
Alert("Please Allow Live Trading");
return(1);
}
else if(!IsDllsAllowed())
{
Alert("Please Allow DLL Import");
return(1);
}
else
{
return(0);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double equity=AccountEquity();
double accbalance=AccountBalance();
int total=OrdersTotal();
if(I***pertEnabled())
{
if(equity<=EquityStop)
{
if(total!=0 && CloseOrder==TRUE)
{
CloseAllTrade();
}
if(disableexpert)
{
DisableEA();
}
Print("Equity Guardian reach equity stop level");
}
if(equity>=EquityTarget)
{
if(total!=0 && CloseOrder==TRUE)
{
CloseAllTrade();
}
if(disableexpert)
{
DisableEA();
}
Print("Equity Guardian reach equity Target level");
}
}
return(0);
}
//disable autotrading
void DisableEA()
{
keybd_event(17,0,0,0);
keybd_event(69,0,0,0);
keybd_event(69,0,2,0);
keybd_event(17,0,2,0);
}
//close all open trade
int CloseAllTrade()
{
int total=OrdersTotal();
int t;
int cnt=0;
for(cnt=0; cnt<=total; cnt++)
{
bool s=OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY)
t=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Violet);
if(OrderType()==OP_SELL)
t=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Violet);
if(OrderType()>OP_SELL) //pending orders
t=OrderDelete(OrderTicket());
}
return(0);
}
//+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#include <WinUser32.mqh>
extern bool CloseOrder=TRUE; //Close All Order
extern bool disableexpert=TRUE; //Disable Expert Advisor
extern double EquityTarget=999999; //Equity Take Profit (USD)
extern double EquityStop=0; //Equity Stop Loss (USD)
//+------------------------------------------------------------------+
//| check live trading and dll |
//+------------------------------------------------------------------+
int OnInit()
{
if(!IsTradeAllowed() && !IsDllsAllowed())
{
Alert("Please Allow Live Trading and DLL Import");
return(1);
}
else if(!IsTradeAllowed())
{
Alert("Please Allow Live Trading");
return(1);
}
else if(!IsDllsAllowed())
{
Alert("Please Allow DLL Import");
return(1);
}
else
{
return(0);
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double equity=AccountEquity();
double accbalance=AccountBalance();
int total=OrdersTotal();
if(I***pertEnabled())
{
if(equity<=EquityStop)
{
if(total!=0 && CloseOrder==TRUE)
{
CloseAllTrade();
}
if(disableexpert)
{
DisableEA();
}
Print("Equity Guardian reach equity stop level");
}
if(equity>=EquityTarget)
{
if(total!=0 && CloseOrder==TRUE)
{
CloseAllTrade();
}
if(disableexpert)
{
DisableEA();
}
Print("Equity Guardian reach equity Target level");
}
}
return(0);
}
//disable autotrading
void DisableEA()
{
keybd_event(17,0,0,0);
keybd_event(69,0,0,0);
keybd_event(69,0,2,0);
keybd_event(17,0,2,0);
}
//close all open trade
int CloseAllTrade()
{
int total=OrdersTotal();
int t;
int cnt=0;
for(cnt=0; cnt<=total; cnt++)
{
bool s=OrderSelect(0,SELECT_BY_POS,MODE_TRADES);
if(OrderType()==OP_BUY)
t=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),5,Violet);
if(OrderType()==OP_SELL)
t=OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),5,Violet);
if(OrderType()>OP_SELL) //pending orders
t=OrderDelete(OrderTicket());
}
return(0);
}
//+------------------------------------------------------------------+
المواضيع المتشابهه | ||||
| الموضوع | كاتب الموضوع | المنتدى | مشاركات | آخر مشاركة |
| طلب عمل اكسبرت من الاستاذ سمير | بشير حمدان | منتدى المؤشرات و الاكسبرتات | 9 | 30 - 10 - 2017 01:59 PM |
| طلب اكسبرت من ملك الاكسبرتات الاستاذ سمير | popo2005 | منتدى المؤشرات و الاكسبرتات | 25 | 30 - 08 - 2017 03:11 PM |
| طلب برمجة اكسبرت من الاستاذ الفاضل سمير | alia123 | منتدى المؤشرات و الاكسبرتات | 20 | 16 - 11 - 2016 07:47 AM |
| اكسبرت مساعد من الاستاذ سمير | mokhtar79 | منتدى المؤشرات و الاكسبرتات | 16 | 06 - 06 - 2014 03:12 AM |
| طلب اكسبرت من الاستاذ سمير ارمان او الاستاذ سفاري | ehab1602 | منتدى المؤشرات و الاكسبرتات | 3 | 03 - 08 - 2012 04:28 AM |