我遇到错误:
EURUSD,H4:OrderSend失败,错误代码为130
专家请指导我在哪里犯错?
void OnTick()
{
H1EMAprev = NormalizeDouble(iMA(NULL,PERIOD_H1,14,0,MODE_EMA,PRICE_CLOSE,1), 5);
H4EMAprev = NormalizeDouble(iMA(NULL,PERIOD_H4,14,0,MODE_EMA,PRICE_CLOSE,1), 5);
StopLossBuy = High[2] + (30 * Point);
StopLossSell = Low[2] - (30 * Point);
if(
Close[1]>H4EMAprev &&
Close[1]>H1EMAprev
)
{
Price = NormalizeDouble(High[1] + (30 * Point), 5);
TpOrderOne = NormalizeDouble(Price + (100 * Point), 5);
//Pending order BUY
Ticket1 = OrderSend(Symbol(),OP_BUYSTOP,1,Price,3,StopLossBuy,TpFirstOrder,"Pending Buy Order 1",16384,0,clrGreen);
if(Ticket1<0)
{
Print("OrderSend failed with error #",GetLastError());
}
else
{
Print("OrderSend placed successfully");
}
}
if(
Close[1]<H4EMAprev &&
Close[1]<H1EMAprev
)
{
Price = NormalizeDouble(Low[1] - (30 * Point), 5);
TpOrderOne = NormalizeDouble(Price - (100 * Point),5 );
//Pending order BUY
Ticket1 = OrderSend(Symbol(),OP_SELLSTOP,1,Price,3,StopLossSell,TpFirstOrder,"Pending Buy Order 1",16384,0,clrGreen);
if(Ticket1<0)
{
Print("OrderSend failed with error #",GetLastError());
}
else
{
Print("OrderSend placed successfully");
}
}
专家请指导我在哪里犯错?
我希望我的EA像这样工作:
开放交易标准:
公开交易价格:
待定买入交易价格将比上一支蜡烛的最高价高3点(即:TradePriceOpen =高[1] + 3点)。
“待定卖出”交易价格将比上一支蜡烛的低点低3点(即:TradePriceOpen =低[1]-3点)。
止损:
止盈:
答案 0 :(得分:0)
您的止损逻辑被颠倒了。您不能在买单上设置高于订单输入价格的止损,反之亦然。