# 如何实现在特定时间买入？

kinglee 2013-05-03 16:46

geneysis 2013-11-19 23:15
//---- input parameters
extern string time_trader_v1.1="visit www.FxAutomated.com for more!!!";
extern double Lots=0.1;
extern int TakeProfit=20;
extern int StopLoss=20;
extern int Slip=5;
extern int SellMagicNumber =10002;
extern string TradeSettings="Mt4 time(min-max): hours 0-23, minutes 0-59, seconds 0-59";
extern bool AllowSell=true;
extern string OurSite="www.FxAutomated.com";

//+------------------------------------------------------------------+
//| expert starts |
//+------------------------------------------------------------------+
int start()
{
//----
int StopMultd,Sleeper=1;

int digits=MarketInfo("EURUSD",MODE_DIGITS);
if(digits==5){StopMultd=10;} else{StopMultd=1;}
double TP=NormalizeDouble(TakeProfit*StopMultd,Digits);
double SL=NormalizeDouble(StopLoss*StopMultd,Digits);
int Slippage=Slip*StopMultd;

// Calculate stop loss
double sls=NormalizeDouble(Bid+SL*Point,Digits);

// Calculate take profit
double tps=NormalizeDouble(Bid-TP*Point,Digits);

//-------------------------------------------------------------------+
//Check open orders
//-------------------------------------------------------------------+
if(OrdersTotal()>0){
for(int i=1; i<=OrdersTotal(); i++) // Cycle searching in orders
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If the next is available
{
if(OrderMagicNumber()==SellMagicNumber) {int halt2=1;}
}
}
}
//-------------------------------------------------------------------+

{
}

}// halt1

if((halt2!=1)&&(AllowSell==true)){// halt2
RefreshRates();
// Sell criteria
{
int opensell=OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,sls,tps,"time trader sell order ",SellMagicNumber,0,Green);
if(opensell<1){int sellfail=1;}
}

}// halt2

//-------------------------------------------------------------------+
// Error processing
//-------------------------------------------------------------------+
int Error=GetLastError();

}

//-------------------------------------------------------------------
return(0);
}
Page 1 of 1 1