下载MetaTrader 5
要添加评论,请登录注册
通过Visa QIWI 钱包向账户存款
hujian
15
hujian 2008.09.15 17:11 

今天编了一下hans系统的改量版,调试到一半出问题

出现了很多

GBPUSD,M30: OrderSend error 130

GBPUSD,M30: OrderSend error 130

GBPUSD,M30: OrderSend error 130

GBPUSD,M30: OrderSend error 130

GBPUSD,M30: OrderSend error 130

GBPUSD,M30: OrderSend error 130

的错误,不知道是为什么

There are many errors "GBPUSD,M30: OrderSend error 130" show up

我很怀疑是不是红色那段代码的问题,因为去掉之后就没有问题了,但不知道为什么?

I greatly doubt about the code in red, cause it won't happen any more when I take out of it .But I don't konw why?

源代码如下 (the source code )

#property copyright "flysnowsword"
#property link "flysnow"

extern int timeframe=30;
extern int BeginSession=4;
extern int LengthSession=4;
extern int takeprofit=60;
extern int stoploss=60;
extern int middleup=30;
extern int middledown=30;
extern double lot1=0.1;
extern double lot2=0.2;
extern double lot3=0.4;


int start()
{
if(Bars>=100 || IsTradeAllowed()==true)

CheckForOpen();
CheckForOrder();

return(0);
}


void CheckForOpen()
{
int magicnum=DayOfYear();
double sellstop;
double buystop;
int ticket_a;
if(TimeHour(TimeCurrent())==BeginSession+LengthSession && TimeMinute(TimeCurrent())==0 && TimeSeconds(TimeCurrent())==0)
{
sellstop=Close[0]-middledown*Point;
buystop=Close[0]+middleup*Point;
//下a定单
ticket_a=OrderSend(Symbol(),OP_SELLSTOP,lot1,sellstop,0,buystop,sellstop-takeprofit*Point,"a",magicnum,0,Green);
if(ticket_a>0)
{
if(OrderSelect(ticket_a,SELECT_BY_TICKET,MODE_TRADES))
Alert(Symbol(),"A卖单已经挂出,价格是:",OrderOpenPrice());
}
else Alert(Symbol(),"A卖单挂单出错:",GetLastError());

ticket_a=OrderSend(Symbol(),OP_BUYSTOP,lot1,buystop,0,sellstop,buystop+takeprofit*Point,"a",magicnum,0,Green);
if(ticket_a>0)
{
if(OrderSelect(ticket_a,SELECT_BY_TICKET,MODE_TRADES))
Alert(Symbol(),"A买单已经挂出,价格是:",OrderOpenPrice());
}
else Alert(Symbol(),"A买单挂单出错:",GetLastError());
}
return;
}


void CheckForOrder()
{
int i,j,k;
int ticket_b;
int testnum;
//double testlot;
//double teststoploss;
//double testopenprice;
for(i=0;i<OrdersTotal();i++)
{
if (OrderSymbol()==Symbol() && OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true)
{
testnum=OrderMagicNumber();
// testlot=OrderLots();
//teststoploss=OrderStopLoss();
//testopenprice=OrderOpenPrice();

if(OrderType()==OP_SELL)
{
for(j=0;j<OrdersTotal();j++)
{
if(OrderSymbol()==Symbol() && OrderSelect(j,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderType()==OP_BUYSTOP && OrderMagicNumber()==testnum && OrderComment()=="a")
{
OrderDelete(OrderTicket());
OrderSend(Symbol(),OP_BUYSTOP,lot2,OrderOpenPrice(),3,OrderStopLoss(),OrderTakeProfit(),"b",testnum,0,Green);
}
}
}
if(OrderComment()=="b")
{
OrderSend(Symbol(),OP_BUYSTOP,lot3,OrderStopLoss(),3,OrderOpenPrice(),OrderStopLoss()+takeprofit*Point,"c",OrderMagicNumber(),0,Green);
}

}

if(OrderType()==OP_BUY)
{
for(k=0;k<OrdersTotal();k++)
{
if(OrderSymbol()==Symbol() && OrderSelect(k,SELECT_BY_POS,MODE_TRADES)==true)
{
if(OrderType()==OP_SELLSTOP && OrderMagicNumber()==testnum && OrderComment()=="a")
{
OrderDelete(OrderTicket());
OrderSend(Symbol(),OP_SELLSTOP,lot2,OrderOpenPrice(),3,OrderStopLoss(),OrderTakeProfit(),"b",testnum,0,Green);
}
}
}
if(OrderComment()=="b")
{
OrderSend(Symbol(),OP_SELLSTOP,lot3,OrderStopLoss(),3,OrderOpenPrice(),OrderStopLoss()+takeprofit*Point,"c",OrderMagicNumber(),0,Green);
}

}
}
}
return(0);
}

topea
74
topea 2008.09.16 02:46  

挂单没有slippage


还有就是要注意止盈止损和开仓价的关系


止盈在亏损位肯定是错的

/
要添加评论,请登录注册