原帖由 cashmere 于 2005-7-21 00:52 发表
好呀!按着费劲吗?我笨.不会弄电脑. h: h:。
#property copyright "Copyright ?2005, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"
//---- input parameters
extern double lowlimit=184.0;
extern double highlimit=204.0;
extern double stopprice=180.0;
extern int stopfloatvalue=400;
extern int takeprofit=30;
extern int takedelta=10;
extern int totallotsnum=250;
extern double lots=0.1;
extern bool type=true;
double Points;
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- TODO: Add your code here.
Points = MarketInfo (Symbol(), MODE_POINT);
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: Add your code here.
//----
return(0);
}
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
int cnt=0, total;
double lastprice;
double delta;
int ordercount;
int ii;
double profitprice;
double firstprice;
double tmpprice;
ordercount=0;
firstprice=0;
if (type==true)
{
lastprice=highlimit;
}
else
{
lastprice=lowlimit;
}
//---- TODO: Add your code here.
total=OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if (type==true)
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
{
ordercount++;
if (lastprice>OrderTakeProfit())
{
lastprice=OrderTakeProfit();
}
}
else if(OrderType()==OP_BUYLIMIT)
{
if (firstprice<OrderTakeProfit())
{
firstprice=OrderTakeProfit();
}
}
}
}
else
{
if(OrderSymbol()==Symbol())
{
if(OrderType()==OP_SELL)
{
ordercount++;
if (lastprice<OrderTakeProfit())
{
lastprice=OrderTakeProfit();
}
}
}
}
}
if (type==true)
{
delta=lastprice-firstprice+Points*1;
ii=delta/(Points*(takeprofit-takedelta));
Print(ii," ",lastprice," ",firstprice);
if (ii>1)
{
for (cnt=0;cnt<ii;cnt++)
{
tmpprice=lastprice-Points*(takeprofit-takedelta);
if (tmpprice-Points*takeprofit>Ask){
OrderSend(Symbol(),OP_BUY,lots,Ask,3,0,tmpprice,"夜猫子",16888,0,Red);
if(GetLastError()==0){
lastprice=tmpprice;
}
else {
cnt--;
}
}
}
//if (firstprice-Points*takeprofit<Ask){
firstprice=lastprice-Points*(takeprofit-takedelta);
OrderSend(Symbol(),OP_BUYLIMIT,lots,firstprice-Points*takeprofit,3,0,firstprice,"夜猫子",16888,0,Red);
//}
}
}
return(0);
}
//+------------------------------------------------------------------+
把上面的拷贝下来,另存为文件 autoorder.mq4
把这个文件拷贝到 metatrader 4 \experts 目录下就可以用了。 |