顺水外汇EA交易网MT4
标题:
跪求大神解决 OrderSend error 130的问题
[打印本页]
作者:
lovetea
时间:
2018-1-11 11:53
标题:
跪求大神解决 OrderSend error 130的问题
我是个菜鸟 不懂代码 求大神行行好 给我简单修改下 把OrderSend error 130问题去掉 我感激不尽
[C++] 纯文本查看 复制代码#property link "waddahattar@hotmail.com"
extern int Step=120;
extern double FirstLot=0.1;
extern double IncLot=0;
extern double MinProfit=450;
extern int Magic = 2008;
double gLotSell=0;
double gLotBuy=0;
double LSP,LBP;
int init()
{
Comment("Waddah Attar Win");
GlobalVariableSet("OldBalance",AccountBalance());
return(0);
}
int deinit()
{
Comment("");
return(0);
}
int start()
{
double i;
double sl,p;
if (AccountEquity()>=GlobalVariableGet("OldBalance")+MinProfit)
{
DeletePendingOrders(Magic);
CloseOrders(Magic);
GlobalVariableSet("OldBalance",0);
}
GlobalVariableSet("OldBalance",AccountBalance());
if (MyOrdersTotal(Magic)==0)
{
OrderSend(Symbol(),OP_BUYLIMIT,FirstLot,Ask-Step*Point,3,0,0,"",Magic,0,Green);
OrderSend(Symbol(),OP_SELLLIMIT,FirstLot,Bid+Step*Point,3,0,0,"",Magic,0,Red);
}
LSP=GetLastSellPrice(Magic);
LBP=GetLastBuyPrice(Magic);
if((LSP-Bid)= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()!=OP_BUY || OrderType()!=OP_SELL))
{
OrderDelete(OrderTicket());
}
}
return(0);
}
int CloseOrders(int Magic)
{
int total = OrdersTotal();
for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
if (OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
return(0);
}
int MyOrdersTotal(int Magic)
{
int c=0;
int total = OrdersTotal();
for (int cnt = 0 ; cnt =0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUYLIMIT || OrderType()==OP_BUY))
{
gLotBuy=OrderLots();
return(OrderOpenPrice());
break;
}
}
return(0);
}
double GetLastSellPrice(int Magic)
{
int total=OrdersTotal()-1;
for (int cnt = total ; cnt >=0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_SELLLIMIT ||OrderType()==OP_SELL))
{
gLotSell=OrderLots();
return(OrderOpenPrice());
break;
}
}
return(100000);
}
作者:
卍马山
时间:
2018-1-11 12:33
你挂单的止损应该设错了,不应该是市价
作者:
注册号
时间:
2018-1-11 12:43
学习学习
作者:
lovetea
时间:
2018-1-11 12:54
这个怎么看 不好意思 我不会看
作者:
zxfzwzy
时间:
2018-1-11 13:05
你看看这样行不行,你的挂单没错,止损止盈没错就没有,所以应该不是130这个问题
#property link "waddahattar@hotmail.com"
extern int Step=120;
extern double FirstLot=0.1;
extern double IncLot=0;
extern double MinProfit=450;
extern int Magic = 2008;
double gLotSell=0;
double gLotBuy=0;
double LSP,LBP;
int init()
{
Comment("Waddah Attar Win");
GlobalVariableSet("OldBalance",AccountBalance());
return(0);
}
int deinit()
{
Comment("");
return(0);
}
int start()
{
double i;
double sl,p;
if (AccountEquity()>=GlobalVariableGet("OldBalance")+MinProfit)
{
DeletePendingOrders(Magic);
CloseOrders(Magic);
GlobalVariableSet("OldBalance",0);
}
GlobalVariableSet("OldBalance",AccountBalance());
if (MyOrdersTotal(Magic)==0)
{
OrderSend(Symbol(),OP_BUYLIMIT,FirstLot,Ask-Step*Point,3,0,0,"",Magic,0,Green);
OrderSend(Symbol(),OP_SELLLIMIT,FirstLot,Bid+Step*Point,3,0,0,"",Magic,0,Red);
}
LSP=GetLastSellPrice(Magic);
LBP=GetLastBuyPrice(Magic);
if((LSP-Bid)= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()!=OP_BUY || OrderType()!=OP_SELL))
{
OrderDelete(OrderTicket());
}
}
return(0);
}
int CloseOrders(int Magic)
{
int total = OrdersTotal();
for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
if (OrderType()==OP_SELL)
{
OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
return(0);
}
int MyOrdersTotal(int Magic)
{
int c=0;
int total = OrdersTotal();
for (int cnt = 0 ; cnt =0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_BUYLIMIT || OrderType()==OP_BUY))
{
gLotBuy=OrderLots();
return(OrderOpenPrice());
}
}
return(0);
}
double GetLastSellPrice(int Magic)
{
int total=OrdersTotal()-1;
for (int cnt = total ; cnt >=0 ; cnt--)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == Magic && OrderSymbol()==Symbol() && (OrderType()==OP_SELLLIMIT ||OrderType()==OP_SELL))
{
gLotSell=OrderLots();
return(OrderOpenPrice());
}
}
return(100000);
}
作者:
lovetea
时间:
2018-1-11 13:59
还是不行 原来就是开始可以下单 后来就出现130错误 再后来又可以下单 最好还是130错误 刚我用你的代码运行了一下 还是这样
作者:
HMGD
时间:
2018-1-11 15:27
有的平台有挂单限制,必须要要远离多少点以外才可以进场,XM,EX都是这样~~~其他的你咨询下平台。
作者:
lovetea
时间:
2018-1-11 16:58
应该是你说的这种情况 我用的EX 要是这种情况 该怎么添加语句呢
作者:
HMGD
时间:
2018-1-11 18:35
先跟平台他们确定挂单间距。double LevelPoint1=挂单间距点差; //注意区分四位或五位平台 4位点值是1=1,5位是1=10
if((OrderType()==OP_SELLLIMIT || OrderType()==OP_SELLSTOP) &&新挂单价格>Bid+LevelPoint1*Point)
{
// 执行挂单逻辑
}
else if((OrderType()==OP_BUYLIMIT ||OrderType()==OP_BUYSTOP)&&新挂单价格>Ask+LevelPoint1*Point)
{
// 执行挂单逻辑
}
else Alert("小于挂单间距,本次挂单未成功",“时间”,货币类型,订单类型)
作者:
stylife-taichi
时间:
2018-1-11 20:08
学习学习,谢谢
作者:
lovetea
时间:
2018-1-11 21:36
谢谢 但是我不懂代码
作者:
winfyha
时间:
2018-1-11 21:41
感謝分享
作者:
yxz0591
时间:
2018-1-11 22:31
extern int Step=120;
extern double FirstLot=0.1;
extern double IncLot=0;
extern double MinProfit=450;
extern int Magic = 2008;
double gLotSell=0;
double gLotBuy=0;
double LSP,LBP;
int init()
{
Comment("Waddah Attar Win");
GlobalVariableSet("OldBalance",AccountBalance());
return(0);
}
int deinit()
{
Comment("");
return(0);
}
int start()
{//double i;double sl,p;
if (AccountEquity()>=GlobalVariableGet("OldBalance")+MinProfit)
{
DeletePendingOrders(Magic);
CloseOrders(Magic);
GlobalVariableSet("OldBalance",0);
}
GlobalVariableSet("OldBalance",AccountBalance());
if (MyOrdersTotal(Magic)==0)
{
bool kcs=OrderSend(Symbol(),OP_BUYLIMIT,FirstLot,Ask-Step*Point,3,0,0,"",Magic,0,Green);
kcs=OrderSend(Symbol(),OP_SELLLIMIT,FirstLot,Bid+Step*Point,3,0,0,"",Magic,0,Red);
}
LSP=GetLastSellPrice(Magic);
LBP=GetLastBuyPrice(Magic);
if((LSP-Bid)= 0 ; cnt--)
{
bool cg=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == M && OrderSymbol()==Symbol() && (OrderType()!=OP_BUY || OrderType()!=OP_SELL))
{
bool scs=OrderDelete(OrderTicket());
}
}
return(0);
}
int CloseOrders(int M)
{
int total = OrdersTotal();
for (int cnt = total-1 ; cnt >= 0 ; cnt--)
{
bool cg=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == M && OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
bool gss=OrderClose(OrderTicket(),OrderLots(),Bid,3);
}
if (OrderType()==OP_SELL)
{
gss=OrderClose(OrderTicket(),OrderLots(),Ask,3);
}
}
}
return(0);
}
int MyOrdersTotal(int M)
{
int c=0;
int total = OrdersTotal();
for (int cnt = 0 ; cnt =0 ; cnt--)
{
bool cg= OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == M && OrderSymbol()==Symbol() && (OrderType()==OP_BUYLIMIT || OrderType()==OP_BUY))
{
gLotBuy=OrderLots();
return(OrderOpenPrice());
}
}
return(0);
}
double GetLastSellPrice(int M)
{
int total=OrdersTotal()-1;
for (int cnt = total ; cnt >=0 ; cnt--)
{
bool cg=OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if (OrderMagicNumber() == M && OrderSymbol()==Symbol() && (OrderType()==OP_SELLLIMIT ||OrderType()==OP_SELL))
{
gLotSell=OrderLots();
return(OrderOpenPrice());
}
}
return(100000);
}
作者:
阳阳_SOgZ7
时间:
2018-1-11 23:39
来学学别人的思路
作者:
uyytgr75kg
时间:
2018-1-12 00:26
谢谢分享。
欢迎光临 顺水外汇EA交易网MT4 (http://waterforex.com/)
Powered by Discuz! X3.2