文章 "轻松快捷开发 MetaTrader 程序的函数库(第 二十四部分):基准交易类 - 无效参数自动纠正" - 页 2 123 新评论 hsyhsy863 2020.02.02 03:25 #11 你好,这两个子程序运行结果不一样,其中“统计时段买亏损”可以得到想结果,而“统计时段卖亏损”结果为0,这是为什么? //统计时间段历史亏损单(已经平仓的单子)数,lasttime为起始时间 double 统计时段买亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime) { double 成交量=0; double 亏损额=0; int 总单数=0; for (int i=OrdersHistoryTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true) { if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对 { if(buyOrSell == "buy") { if (OrderType() == OP_BUY ) { if (OrderCloseTime()>lasttime) { if (OrderProfit()<0) { 总单数=总单数+1; 亏损额=亏损额+OrderProfit(); 成交量=成交量+OrderLots(); } } } } } }} if (as_8 == "总单数") return (总单数); if (as_8 == "亏损额") return (亏损额); if (as_8 == "成交量") return (成交量); return (0.0); } double 统计时段卖亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime) { double 成交量=0; double 亏损额=0; int 总单数=0; for (int i=OrdersHistoryTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true) { if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对 { if(buyOrSell == "sell") { if (OrderType() == OP_SELL ) { if (OrderCloseTime()>lasttime) { if (OrderProfit()<0) { 总单数=总单数+1; 亏损额=亏损额+OrderProfit(); 成交量=成交量+OrderLots(); } } } } } }} if (as_8 == "总单数") return (总单数); if (as_8 == "亏损额") return (亏损额); if (as_8 == "成交量") return (成交量); return (0.0); } 如何编码? How to 'Stop' an 关闭订单的利润计算 "HELP" hsyhsy863 2020.02.02 03:30 #12 你好,这两个子程序运行结果不一样,其中“统计时段买亏损”可以得到想结果,而“统计时段卖亏损”结果为0,这是为什么? //统计时间段历史亏损单(已经平仓的单子)数,lasttime为起始时间 double 统计时段买亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime) { double 成交量=0; double 亏损额=0; int 总单数=0; for (int i=OrdersHistoryTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true) { if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对 { if(buyOrSell == "buy") { if (OrderType() == OP_BUY ) { if (OrderCloseTime()>lasttime) { if (OrderProfit()<0) { 总单数=总单数+1; 亏损额=亏损额+OrderProfit(); 成交量=成交量+OrderLots(); } } } } } }} if (as_8 == "总单数") return (总单数); if (as_8 == "亏损额") return (亏损额); if (as_8 == "成交量") return (成交量); return (0.0); } double 统计时段卖亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime) { double 成交量=0; double 亏损额=0; int 总单数=0; for (int i=OrdersHistoryTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true) { if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对 { if(buyOrSell == "sell") { if (OrderType() == OP_SELL ) { if (OrderCloseTime()>lasttime) { if (OrderProfit()<0) { 总单数=总单数+1; 亏损额=亏损额+OrderProfit(); 成交量=成交量+OrderLots(); } } } } } }} if (as_8 == "总单数") return (总单数); if (as_8 == "亏损额") return (亏损额); if (as_8 == "成交量") return (成交量); return (0.0); } 如何编码? How to 'Stop' an 关闭订单的利润计算 "HELP" hsyhsy863 2020.02.02 03:41 #13 Artyom Trishkin: OK 你好,这两个子程序运行结果不一样,其中“统计时段买亏损”可以得到想结果,而“统计时段卖亏损”结果为0,这是为什么? //统计时间段历史亏损单(已经平仓的单子)数,lasttime为起始时间 double 统计时段买亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime) { double 成交量=0; double 亏损额=0; int 总单数=0; for (int i=OrdersHistoryTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true) { if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对 { if(buyOrSell == "buy") { if (OrderType() == OP_BUY ) { if (OrderCloseTime()>lasttime) { if (OrderProfit()<0) { 总单数=总单数+1; 亏损额=亏损额+OrderProfit(); 成交量=成交量+OrderLots(); } } } } } }} if (as_8 == "总单数") return (总单数); if (as_8 == "亏损额") return (亏损额); if (as_8 == "成交量") return (成交量); return (0.0); } double 统计时段卖亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime) { double 成交量=0; double 亏损额=0; int 总单数=0; for (int i=OrdersHistoryTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true) { if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对 { if(buyOrSell == "sell") { if (OrderType() == OP_SELL ) { if (OrderCloseTime()>lasttime) { if (OrderProfit()<0) { 总单数=总单数+1; 亏损额=亏损额+OrderProfit(); 成交量=成交量+OrderLots(); } } } } } }} if (as_8 == "总单数") return (总单数); if (as_8 == "亏损额") return (亏损额); if (as_8 == "成交量") return (成交量); return (0.0); } 如何编码? How to 'Stop' an 关闭订单的利润计算 "HELP" Artyom Trishkin 2020.02.02 03:57 #14 This is a discussion thread for the article, and not for resolving issues not related to the library described in the article. To insert the code into the message, you need to use the Alt + S combination or this button: hsyhsy863 2020.02.02 04:52 #15 你好,是否本程序不支持对历史成交卖单的查询? Artyom Trishkin 2020.02.02 06:59 #16 hsyhsy863 : 你好,是否本程序不支持对历史成交卖单的查询? It supports. And even much more. hsyhsy863 2020.02.06 06:42 #17 你好,我在使用过程中发现,当加载有自定义指标,然后删除自定义指标这时按键就失灵了,没办法操作。这是为什么?如何解决? Artyom Trishkin 2020.02.06 13:49 #18 hsyhsy863 : 你好,我在使用过程中发现,当加载有自定义指标,然后删除自定义指标这时按键就失灵了,没办法操作。这是为什么?如何解决? During use - what? Which keys do not work? hsyhsy863 2020.02.08 01:31 #19 我想发一个自定义指标给你,你把它加载后删掉,试试就明白。 附加的文件: jh720-03-3.ex4 214 kb hsyhsy863 2020.02.10 05:00 #20 hsyhsy863: 我想发一个自定义指标给你,你把它加载后删掉,试试就明白。 你好,我提的问题发现了吗? 123 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
你好,这两个子程序运行结果不一样,其中“统计时段买亏损”可以得到想结果,而“统计时段卖亏损”结果为0,这是为什么?
//统计时间段历史亏损单(已经平仓的单子)数,lasttime为起始时间
double 统计时段买亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime)
{
double 成交量=0;
double 亏损额=0;
int 总单数=0;
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
{
if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对
{
if(buyOrSell == "buy")
{
if (OrderType() == OP_BUY )
{
if (OrderCloseTime()>lasttime)
{
if (OrderProfit()<0)
{
总单数=总单数+1;
亏损额=亏损额+OrderProfit();
成交量=成交量+OrderLots();
}
}
}
}
}
}}
if (as_8 == "总单数") return (总单数);
if (as_8 == "亏损额") return (亏损额);
if (as_8 == "成交量") return (成交量);
return (0.0);
}
double 统计时段卖亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime)
{
double 成交量=0;
double 亏损额=0;
int 总单数=0;
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
{
if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对
{
if(buyOrSell == "sell")
{
if (OrderType() == OP_SELL )
{
if (OrderCloseTime()>lasttime)
{
if (OrderProfit()<0)
{
总单数=总单数+1;
亏损额=亏损额+OrderProfit();
成交量=成交量+OrderLots();
}
}
}
}
}
}}
if (as_8 == "总单数") return (总单数);
if (as_8 == "亏损额") return (亏损额);
if (as_8 == "成交量") return (成交量);
return (0.0);
}
你好,这两个子程序运行结果不一样,其中“统计时段买亏损”可以得到想结果,而“统计时段卖亏损”结果为0,这是为什么?
//统计时间段历史亏损单(已经平仓的单子)数,lasttime为起始时间
double 统计时段买亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime)
{
double 成交量=0;
double 亏损额=0;
int 总单数=0;
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
{
if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对
{
if(buyOrSell == "buy")
{
if (OrderType() == OP_BUY )
{
if (OrderCloseTime()>lasttime)
{
if (OrderProfit()<0)
{
总单数=总单数+1;
亏损额=亏损额+OrderProfit();
成交量=成交量+OrderLots();
}
}
}
}
}
}}
if (as_8 == "总单数") return (总单数);
if (as_8 == "亏损额") return (亏损额);
if (as_8 == "成交量") return (成交量);
return (0.0);
}
double 统计时段卖亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime)
{
double 成交量=0;
double 亏损额=0;
int 总单数=0;
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
{
if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对
{
if(buyOrSell == "sell")
{
if (OrderType() == OP_SELL )
{
if (OrderCloseTime()>lasttime)
{
if (OrderProfit()<0)
{
总单数=总单数+1;
亏损额=亏损额+OrderProfit();
成交量=成交量+OrderLots();
}
}
}
}
}
}}
if (as_8 == "总单数") return (总单数);
if (as_8 == "亏损额") return (亏损额);
if (as_8 == "成交量") return (成交量);
return (0.0);
}
OK
你好,这两个子程序运行结果不一样,其中“统计时段买亏损”可以得到想结果,而“统计时段卖亏损”结果为0,这是为什么?
//统计时间段历史亏损单(已经平仓的单子)数,lasttime为起始时间
double 统计时段买亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime)
{
double 成交量=0;
double 亏损额=0;
int 总单数=0;
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
{
if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对
{
if(buyOrSell == "buy")
{
if (OrderType() == OP_BUY )
{
if (OrderCloseTime()>lasttime)
{
if (OrderProfit()<0)
{
总单数=总单数+1;
亏损额=亏损额+OrderProfit();
成交量=成交量+OrderLots();
}
}
}
}
}
}}
if (as_8 == "总单数") return (总单数);
if (as_8 == "亏损额") return (亏损额);
if (as_8 == "成交量") return (成交量);
return (0.0);
}
double 统计时段卖亏损(int 魔号,string buyOrSell, string as_8,datetime lasttime)
{
double 成交量=0;
double 亏损额=0;
int 总单数=0;
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)==true)
{
if (OrderSymbol() == Symbol()&& OrderMagicNumber()==魔号 )//只统计当前对应货币对
{
if(buyOrSell == "sell")
{
if (OrderType() == OP_SELL )
{
if (OrderCloseTime()>lasttime)
{
if (OrderProfit()<0)
{
总单数=总单数+1;
亏损额=亏损额+OrderProfit();
成交量=成交量+OrderLots();
}
}
}
}
}
}}
if (as_8 == "总单数") return (总单数);
if (as_8 == "亏损额") return (亏损额);
if (as_8 == "成交量") return (成交量);
return (0.0);
}
This is a discussion thread for the article, and not for resolving issues not related to the library described in the article.
To insert the code into the message, you need to use the Alt + S combination or this button:
你好,是否本程序不支持对历史成交卖单的查询?
It supports. And even much more.
你好,我在使用过程中发现,当加载有自定义指标,然后删除自定义指标这时按键就失灵了,没办法操作。这是为什么?如何解决?
During use - what?
Which keys do not work?我想发一个自定义指标给你,你把它加载后删掉,试试就明白。