//+------------------------------------------------------------------+ //| EA_E-mail.mq4 | //| triadinvest@yahoo.fr| //| //+------------------------------------------------------------------+ #property copyright "triadinvest@yahoo.fr" #property link "itriad" //---- input parameters extern int TimeInterval= 3; // xx Seconds to send the order extern double lotsize = 0.001; int res = 0; int Magic = 12345; double SumLots = 0; //+------------------------------------------------------------------+ //| expert initialization function | //+------------------------------------------------------------------+ int init() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| expert start function | //+------------------------------------------------------------------+ int start() { SumLots = 0; for (int i = 0; i < OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) { SumLots = SumLots + OrderLots(); } } while(TimeInterval>0 && SumLots < 10) { RefreshRates(); res=OrderSend(Symbol(), OP_BUY,lotsize,Ask,0,0,0,NULL,Magic,0,Green); if(res > 0) { OrderSelect(res,SELECT_BY_TICKET,MODE_TRADES); SumLots = SumLots + OrderLots(); } res=OrderSend(Symbol(),OP_SELL,lotsize,Bid,0,0,0,NULL,Magic,0,Red); if(res > 0) { OrderSelect(res,SELECT_BY_TICKET,MODE_TRADES); SumLots = SumLots + OrderLots(); } Sleep( TimeInterval*1*1000);//sleep in miliseconds, so use 60*1000 to change to minute } //---- return(0); } //+------------------------------------------------------------------+
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
example:i start my expert and if open position reach 10 lots wait(break) until open position comback <10 lots?
//+------------------------------------------------------------------+
//| EA_E-mail.mq4 |
//| triadinvest@yahoo.fr|
//|
//+------------------------------------------------------------------+
#property copyright "triadinvest@yahoo.fr"
#property link "itriad"
//---- input parameters
extern int TimeInterval= 1; // xx minutes to send the order
extern int lotsize = 0.001;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
while(TimeInterval>0)
{
OrderSend(Symbol(), OP_BUY,lotsize,MarketInfo("EURUSD",MODE_ASK),0,1.3063,0);//GO LONG
OrderSend(Symbol(),OP_SELL,lotsize,MarketInfo("EURUSD",MODE_BID),0,1.3067,0);//GO SHORT
Sleep( TimeInterval*100);//sleep in miliseconds, so use 60*1000 to change to minute
}
//----
return(0);
}
//+------------------------------------------------------------------+