如何编码? - 页 283 1...276277278279280281282283284285286287288289290...347 新评论 Beno 2011.12.21 22:05 #2821 请提供数学期望值的帮助 你好 我似乎在一定程度上欺骗了自己。 我试图在我的EA中使用一个期望值公式,我有一个公式1-avgwin/avgloss*system accuracy+1,这个公式运行良好,但是我想知道如何计算并显示订单和止损之间的差异,例如 op_sellstop 1.63406 StopLoss 1.63603 1.63406 - 1.63603 = -0.00197 我认为这需要是一个正数。 期望值为1.45 所以为了计算获利,-0.00197 * 1.45 = -0.00285 将TP放在OP_SELLSTOP 1.63406 -1.63121 处 反之亦然,对于多头头寸,也是如此。 这都是这个主题的一部分https://www.mql5.com/en/forum/178980,如果你看一下excel表,你会发现我就快成功了。 任何帮助都将是巨大的。 谢谢你,贝诺 crn 2011.12.22 16:07 #2822 Beno: 你好我似乎在一定程度上欺骗了自己。 我试图在我的EA中使用一个期望公式,我有一个公式1-avgwin/avgloss*system accuracy+1,这个公式运行良好,但是我想知道如何计算并显示订单和止损之间的差异,例如 op_sellstop 1.63406 StopLoss 1.63603 1.63406 - 1.63603 = -0.00197 我认为这需要是一个正数。 期望值为1.45 所以为了计算获利,-0.00197 * 1.45 = -0.00285 将TP放在OP_SELLSTOP 1.63406 -1.63121 处 反之亦然,对于多头头寸,也是如此。 这都是这个主题的一部分https://www.mql5.com/en/forum/178980,如果你看一下excel表,你会发现我就快成功了。 任何帮助都将是巨大的。 欢呼声 贝诺 最简单的方法是不考虑这个问题,使用。 double MathAbs(double value) MathAbs - MQL4文档 注意事项 Beno 2011.12.22 17:56 #2823 嗨,CRN 谢谢你的回答,这是我一直在尝试的。 double PipSL = MathAbs (OrderOpenPrice() - StopLoss); Print (MathAbs (OrderOpenPrice() - StopLoss)); 我认为这是正确的,但只是打印出PipSL 15769.68328362 1 2011.01.04 00:00 卖出停止 1 0.01 1.54279 0.00000 0.00000 0.00 10000.00 2 2011.01.07 08:20 卖出 1 0.01 1.54279 0.00000 0.00000 0.00 10000.00 3 2011.01.07 08:20 修改 1 0.01 1.54279 1.57712 0.00000 0.00 10000.00 4 2011.01.11 23:40 收盘于止损 1 0.01 1.56045 1.57712 0.00000 -17.66 9982.34 我需要卖出和止损之间的实际差异 How to code? Looking for an EA BrainSystem: Trading System Development miemobil 2011.12.23 14:52 #2824 谁能帮帮我? 大家好,祝大家圣诞快乐。 首先,我是这个论坛的新人。我遇到了关于EA的问题,谁能帮我解决一下?问题是如何将这个EA设置为真实交易,而在我的真实交易中,这个EA只是灰色的。 这里有一个附件。 spielershedge_library.mqh spielershedge_pipstar.mq4 spielershedge_ea_v2.8.1.ex4 差异_v5.1.ex4 -虽然它是旧的EA,但我想也许我们可以分享并采取一些对我们所有人都有益的东西。 我刚刚从对冲交易的spieler系统 中找到了这个源自期货价差交易--第193页@外汇工厂(SpielersHedge PipStar.mq4),其余的来自对冲交易spieler系统,源自期货价差交易--第87页@外汇工厂 -对不起,我的英语不好。 P/S :我非常感谢你们为我的进步而提供的课程、指导、评论和批评。我相信我们付出的知识越多,我们获得的知识就越多。 附加的文件: spielershedge_divergence_v5.1.ex4 14 kb spielershedge_ea_v2.8.1.ex4 45 kb spielershedge_pipstar.mq4 51 kb spielershedge_library.mqh 13 kb crn 2011.12.23 21:57 #2825 Beno: 嗨,CRN 谢谢你的回答,这是我一直在尝试的。double PipSL = MathAbs (OrderOpenPrice() - StopLoss); Print (MathAbs (OrderOpenPrice() - StopLoss));我认为这是正确的,但只是打印出PipSL 15769.683283621 2011.01.04 00:00 卖出停止 1 0.01 1.54279 0.00000 0.00000 0.00 10000.002 2011.01.07 08:20 卖出 1 0.01 1.54279 0.00000 0.00000 0.00 10000.003 2011.01.07 08:20 修改 1 0.01 1.54279 1.57712 0.00000 0.00 10000.004 2011.01.11 23:40 平仓止损 1 0.01 1.56045 1.57712 0.00000 -17.66 9982.34 我需要的是卖出和SL之间的实际差异 如果你需要实际使用iClose(0,0,0)-OrderStopLoss()。 但首先通过OrderSelect选择合适的订单。 注意事项 Beno 2011.12.28 15:06 #2826 使用CloseAll的时间过滤器,请帮助 尊敬的先生 我有一个在EA上工作的时间过滤器,但我一直试图在它上面附加一个closeall,所以如果时间等于收盘时间,那么closeall就会打开位置。 extern string timefilter="Time Filter"; extern int gmtshift=1; // gmt offset of the broker extern bool generalfilter=false; // enable time filter extern int starthour=7; // start hour to trade after this hour extern int startminutes=0; // minutes of the start hour extern int endhour=21; // stop to trade after this hour extern int endminutes=0; // minutes of the start hour extern bool tradesunday=true; // trade on sunday extern bool fridayfilter=false; // enable special time filter on friday extern int fridayhour=21; // stop to trade after this hour extern int fridayminutes=0; // minutes of the friday hour[/CODE] [CODE]void start() { if(generalfilter){ nstarthour=starthour+(gmtshift);if(nstarthour>23)nstarthour=nstarthour-24; if(nstarthour<10)istarthour="0"+nstarthour; if(nstarthour>9)istarthour=nstarthour; if(startminutes<10)istartminutes="0"+startminutes; if(startminutes>9)istartminutes=startminutes; tstart=StrToTime(istarthour+":"+istartminutes); nendhour=endhour+(gmtshift);if(nendhour>23)nendhour=nendhour-24; if(endhour<10)iendhour="0"+nendhour; if(endhour>9)iendhour=nendhour; if(endminutes<10)iendminutes="0"+endminutes; if(endminutes>9)iendminutes=endminutes; tend=StrToTime(iendhour+":"+iendminutes); } if(fridayfilter){ nfridayhour=fridayhour+(gmtshift);if(nfridayhour>23)nfridayhour=nfridayhour-24; if(nfridayhour<10)ifridayhour="0"+nfridayhour; if(nfridayhour>9)ifridayhour=nfridayhour; if(fridayminutes<10)ifridayminutes="0"+fridayminutes; if(fridayminutes>9)ifridayminutes=fridayminutes; tfriday=StrToTime(ifridayhour+":"+ifridayminutes); } if((generalfilter && (nstarthour<nendhour && TimeCurrent()tend) || (nstarthour>nendhour && TimeCurrent()tend)) || (tradesunday==false && DayOfWeek()==0) || (fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday))return(0); if (TimeCurrent() >= tend) { for (int i=OrdersTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==TradeSymbol) { if (OrderType()==OP_BUY) { pBid=MarketInfo(OrderSymbol(), MODE_BID); OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Yellow); } if (OrderType()==OP_SELL) { pAsk=MarketInfo(OrderSymbol(), MODE_ASK); OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange); } } } } } How to code? 求助,我想请高手朋友们写一个 止盈--止损脚本 问吧! rizkyd 2011.12.29 01:10 #2827 请帮助我 extern int BuyStopTakeProfit=10; extern int BuyStopSL=1000; 如何编写代码 如果BuyStopTakeProfit 击中TakeProfit,删除所有挂单 请任何人帮助。 cmfxtrader 2011.12.29 02:25 #2828 帮助!!!! 请!!!! iCustom函数 帮助。 我想尽一切办法让我的C_EA_rev6.mq4调用自定义指标 VSATEXTSIGNALS.mq4中的任何缓冲区。 我使用了iCustom函数,但它总是返回2147483647,我知道这是一个错误代码。 该自定义指标根据成交量分布分析技术在图表上放置文本信号。 当我把自定义指标附加到图表上时,它运行良好。 我在这方面花了无数的时间,尝试了所有我知道的组合。 如果有任何帮助,我将不胜感激。 另外,我有个问题,你能在调用脚本或.dll文件的自定义指标上使用iCustom功能吗? 见附件中的指标和EA的代码。 谢谢。 cmfxtrader 附加的文件: c_ea_rev6.mq4 11 kb vsatextsignals.mq4 14 kb Kale 2011.12.29 05:57 #2829 cmfxtrader: 帮助。我已经尝试了各种方法让我的C_EA_rev6.mq4调用自定义指标VSATEXTSIGNALS.mq4的任何缓冲区。 我使用了iCustom函数,但它总是返回2147483647,我知道这是一个错误代码。 该自定义指标根据成交量分布分析技术在图表上放置文本信号。 当我把自定义指标附加到图表上时,它运行良好。 我在这方面花了无数的时间,尝试了所有我知道的组合。 如果有任何帮助,我将不胜感激。 另外,我有个问题,你能在调用脚本或.dll文件的自定义指标上使用iCustom功能吗? 见附件中的指标和EA的代码。 谢谢。 cmfxtrader 嘿。 问题是,当你试图从指标中读取缓冲区时,它输出的是文本信息,而这不是缓冲区。因此,为什么你会得到2147483647的值,这是EMPTY_VALUE,而不是一个错误。 无论如何,我猜你想从这个指标中自动获取信号。对此有一个简单的解决方案。该指标被声明为有7个缓冲区(#属性 indicator_buffers 7),但它只使用了5个。 指标最多可使用8个缓冲区。这意味着你可以为你的计算声明另一个额外的缓冲区,并用信息标识来填充它。你可以在TextOutput函数中找到信息编号。简单地将数字添加到缓冲区,这取决于显示的信息。例如,如果文本是:"UPTHRUST / Weakness_",那么就在缓冲区里加1,如果信息是PSEUDO UPTHRUST / Weakness_,就加4,以此类推。缓冲区的索引将与 "i "变量的值相同。 至于你的第二个问题:你总是可以对一个指标(而不是脚本)使用iCustom函数,如果它填补了指标中声明的缓冲区,就可以读取其值。例如,如果这将是一个画线的指标,那么你可以读取线的值 - 因为要画一些东西(除了标签),指标必须填充缓冲区。如果该指标将创建图形对象(像你所附的那个),那么你将需要:a)从图形对象中读取数值,或者b)重新编码指标(像我上面建议的那样)。指标是否使用DLL并不重要--它只需要正确填充缓冲区,以便从iCustom函数中读取数值。 Kale 2011.12.29 06:32 #2830 Beno: 日子 我在EA上有一个时间过滤器,但我一直想给它附加一个平仓功能,如果时间等于收盘时间,那么平仓。extern string timefilter="Time Filter"; extern int gmtshift=1; // gmt offset of the broker extern bool generalfilter=false; // enable time filter extern int starthour=7; // start hour to trade after this hour extern int startminutes=0; // minutes of the start hour extern int endhour=21; // stop to trade after this hour extern int endminutes=0; // minutes of the start hour extern bool tradesunday=true; // trade on sunday extern bool fridayfilter=false; // enable special time filter on friday extern int fridayhour=21; // stop to trade after this hour extern int fridayminutes=0; // minutes of the friday hour[/CODE] [CODE]void start() { if(generalfilter){ nstarthour=starthour+(gmtshift);if(nstarthour>23)nstarthour=nstarthour-24; if(nstarthour<10)istarthour="0"+nstarthour; if(nstarthour>9)istarthour=nstarthour; if(startminutes<10)istartminutes="0"+startminutes; if(startminutes>9)istartminutes=startminutes; tstart=StrToTime(istarthour+":"+istartminutes); nendhour=endhour+(gmtshift);if(nendhour>23)nendhour=nendhour-24; if(endhour<10)iendhour="0"+nendhour; if(endhour>9)iendhour=nendhour; if(endminutes<10)iendminutes="0"+endminutes; if(endminutes>9)iendminutes=endminutes; tend=StrToTime(iendhour+":"+iendminutes); } if(fridayfilter){ nfridayhour=fridayhour+(gmtshift);if(nfridayhour>23)nfridayhour=nfridayhour-24; if(nfridayhour<10)ifridayhour="0"+nfridayhour; if(nfridayhour>9)ifridayhour=nfridayhour; if(fridayminutes<10)ifridayminutes="0"+fridayminutes; if(fridayminutes>9)ifridayminutes=fridayminutes; tfriday=StrToTime(ifridayhour+":"+ifridayminutes); } if((generalfilter && (nstarthour<nendhour && TimeCurrent()tend) || (nstarthour>nendhour && TimeCurrent()tend)) || (tradesunday==false && DayOfWeek()==0) || (fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday))return(0); if (TimeCurrent() >= tend) { for (int i=OrdersTotal()-1; i>=0; i--) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) { if (OrderSymbol()==TradeSymbol) { if (OrderType()==OP_BUY) { pBid=MarketInfo(OrderSymbol(), MODE_BID); OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Yellow); } if (OrderType()==OP_SELL) { pAsk=MarketInfo(OrderSymbol(), MODE_ASK); OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange); } } } } } 试着检查一下 这部分。 if((generalfilter && (nstarthour<nendhour && TimeCurrent()tend) || (nstarthour>nendhour && TimeCurrent()tend)) || ( tradesunday==false && DayOfWeek()==0)|| (fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday))返回(0)。 代码的其他部分可能更简单,但它应该是有效的。 然而,如果你在关闭所有部分之前退出脚本,那么它就不会工作,而且似乎脚本正在这样做。 请看一下这部分的例子。 (fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday) return(0)。 英文的意思是:如果是星期五,并且星期五过滤器是打开的,并且时间标记已经通过(例如,结束时间是18.00,现在是18.01),那么返回(0)。 它应该是:如果它是星期五,并且星期五过滤器是开着的,并且时间标记是通过关闭所有和(例如,结束时间是18.00和它是18.01)然后返回(0)。 How to code? 1...276277278279280281282283284285286287288289290...347 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
请提供数学期望值的帮助
你好
我似乎在一定程度上欺骗了自己。
我试图在我的EA中使用一个期望值公式,我有一个公式1-avgwin/avgloss*system accuracy+1,这个公式运行良好,但是我想知道如何计算并显示订单和止损之间的差异,例如
op_sellstop 1.63406
StopLoss 1.63603
1.63406 - 1.63603 = -0.00197 我认为这需要是一个正数。
期望值为1.45
所以为了计算获利,-0.00197 * 1.45 = -0.00285
将TP放在OP_SELLSTOP 1.63406 -1.63121 处
反之亦然,对于多头头寸,也是如此。
这都是这个主题的一部分https://www.mql5.com/en/forum/178980,如果你看一下excel表,你会发现我就快成功了。
任何帮助都将是巨大的。
谢谢你,贝诺
你好
我似乎在一定程度上欺骗了自己。
我试图在我的EA中使用一个期望公式,我有一个公式1-avgwin/avgloss*system accuracy+1,这个公式运行良好,但是我想知道如何计算并显示订单和止损之间的差异,例如
op_sellstop 1.63406
StopLoss 1.63603
1.63406 - 1.63603 = -0.00197 我认为这需要是一个正数。
期望值为1.45
所以为了计算获利,-0.00197 * 1.45 = -0.00285
将TP放在OP_SELLSTOP 1.63406 -1.63121 处
反之亦然,对于多头头寸,也是如此。
这都是这个主题的一部分https://www.mql5.com/en/forum/178980,如果你看一下excel表,你会发现我就快成功了。
任何帮助都将是巨大的。
欢呼声 贝诺最简单的方法是不考虑这个问题,使用。
double MathAbs(double value)
MathAbs - MQL4文档
注意事项
嗨,CRN
谢谢你的回答,这是我一直在尝试的。
我认为这是正确的,但只是打印出PipSL 15769.68328362
1 2011.01.04 00:00 卖出停止 1 0.01 1.54279 0.00000 0.00000 0.00 10000.00
2 2011.01.07 08:20 卖出 1 0.01 1.54279 0.00000 0.00000 0.00 10000.00
3 2011.01.07 08:20 修改 1 0.01 1.54279 1.57712 0.00000 0.00 10000.00
4 2011.01.11 23:40 收盘于止损 1 0.01 1.56045 1.57712 0.00000 -17.66 9982.34
我需要卖出和止损之间的实际差异
谁能帮帮我?
大家好,祝大家圣诞快乐。
首先,我是这个论坛的新人。我遇到了关于EA的问题,谁能帮我解决一下?问题是如何将这个EA设置为真实交易,而在我的真实交易中,这个EA只是灰色的。
这里有一个附件。
spielershedge_library.mqh
spielershedge_pipstar.mq4
spielershedge_ea_v2.8.1.ex4
差异_v5.1.ex4
-虽然它是旧的EA,但我想也许我们可以分享并采取一些对我们所有人都有益的东西。
我刚刚从对冲交易的spieler系统 中找到了这个源自期货价差交易--第193页@外汇工厂(SpielersHedge PipStar.mq4),其余的来自对冲交易spieler系统,源自期货价差交易--第87页@外汇工厂
-对不起,我的英语不好。
P/S :我非常感谢你们为我的进步而提供的课程、指导、评论和批评。我相信我们付出的知识越多,我们获得的知识就越多。
嗨,CRN
谢谢你的回答,这是我一直在尝试的。
我认为这是正确的,但只是打印出PipSL 15769.68328362
1 2011.01.04 00:00 卖出停止 1 0.01 1.54279 0.00000 0.00000 0.00 10000.00
2 2011.01.07 08:20 卖出 1 0.01 1.54279 0.00000 0.00000 0.00 10000.00
3 2011.01.07 08:20 修改 1 0.01 1.54279 1.57712 0.00000 0.00 10000.00
4 2011.01.11 23:40 平仓止损 1 0.01 1.56045 1.57712 0.00000 -17.66 9982.34
我需要的是卖出和SL之间的实际差异如果你需要实际使用iClose(0,0,0)-OrderStopLoss()。
但首先通过OrderSelect选择合适的订单。
注意事项
使用CloseAll的时间过滤器,请帮助
尊敬的先生
我有一个在EA上工作的时间过滤器,但我一直试图在它上面附加一个closeall,所以如果时间等于收盘时间,那么closeall就会打开位置。
extern int gmtshift=1; // gmt offset of the broker
extern bool generalfilter=false; // enable time filter
extern int starthour=7; // start hour to trade after this hour
extern int startminutes=0; // minutes of the start hour
extern int endhour=21; // stop to trade after this hour
extern int endminutes=0; // minutes of the start hour
extern bool tradesunday=true; // trade on sunday
extern bool fridayfilter=false; // enable special time filter on friday
extern int fridayhour=21; // stop to trade after this hour
extern int fridayminutes=0; // minutes of the friday hour[/CODE]
[CODE]void start() {
if(generalfilter){
nstarthour=starthour+(gmtshift);if(nstarthour>23)nstarthour=nstarthour-24;
if(nstarthour<10)istarthour="0"+nstarthour;
if(nstarthour>9)istarthour=nstarthour;
if(startminutes<10)istartminutes="0"+startminutes;
if(startminutes>9)istartminutes=startminutes;
tstart=StrToTime(istarthour+":"+istartminutes);
nendhour=endhour+(gmtshift);if(nendhour>23)nendhour=nendhour-24;
if(endhour<10)iendhour="0"+nendhour;
if(endhour>9)iendhour=nendhour;
if(endminutes<10)iendminutes="0"+endminutes;
if(endminutes>9)iendminutes=endminutes;
tend=StrToTime(iendhour+":"+iendminutes);
}
if(fridayfilter){
nfridayhour=fridayhour+(gmtshift);if(nfridayhour>23)nfridayhour=nfridayhour-24;
if(nfridayhour<10)ifridayhour="0"+nfridayhour;
if(nfridayhour>9)ifridayhour=nfridayhour;
if(fridayminutes<10)ifridayminutes="0"+fridayminutes;
if(fridayminutes>9)ifridayminutes=fridayminutes;
tfriday=StrToTime(ifridayhour+":"+ifridayminutes);
}
if((generalfilter && (nstarthour<nendhour && TimeCurrent()tend) || (nstarthour>nendhour && TimeCurrent()tend))
|| (tradesunday==false && DayOfWeek()==0) || (fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday))return(0);
if (TimeCurrent() >= tend) {
for (int i=OrdersTotal()-1; i>=0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==TradeSymbol) {
if (OrderType()==OP_BUY) {
pBid=MarketInfo(OrderSymbol(), MODE_BID);
OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Yellow);
}
if (OrderType()==OP_SELL) {
pAsk=MarketInfo(OrderSymbol(), MODE_ASK);
OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);
}
}
}
}
}请帮助我
extern int BuyStopTakeProfit=10;
extern int BuyStopSL=1000;
如何编写代码
如果BuyStopTakeProfit 击中TakeProfit,删除所有挂单
请任何人帮助。
帮助!!!! 请!!!! iCustom函数
帮助。
我想尽一切办法让我的C_EA_rev6.mq4调用自定义指标 VSATEXTSIGNALS.mq4中的任何缓冲区。 我使用了iCustom函数,但它总是返回2147483647,我知道这是一个错误代码。 该自定义指标根据成交量分布分析技术在图表上放置文本信号。 当我把自定义指标附加到图表上时,它运行良好。 我在这方面花了无数的时间,尝试了所有我知道的组合。 如果有任何帮助,我将不胜感激。 另外,我有个问题,你能在调用脚本或.dll文件的自定义指标上使用iCustom功能吗?
见附件中的指标和EA的代码。
谢谢。
cmfxtrader
帮助。
我已经尝试了各种方法让我的C_EA_rev6.mq4调用自定义指标VSATEXTSIGNALS.mq4的任何缓冲区。 我使用了iCustom函数,但它总是返回2147483647,我知道这是一个错误代码。 该自定义指标根据成交量分布分析技术在图表上放置文本信号。 当我把自定义指标附加到图表上时,它运行良好。 我在这方面花了无数的时间,尝试了所有我知道的组合。 如果有任何帮助,我将不胜感激。 另外,我有个问题,你能在调用脚本或.dll文件的自定义指标上使用iCustom功能吗?
见附件中的指标和EA的代码。
谢谢。
cmfxtrader嘿。
问题是,当你试图从指标中读取缓冲区时,它输出的是文本信息,而这不是缓冲区。因此,为什么你会得到2147483647的值,这是EMPTY_VALUE,而不是一个错误。
无论如何,我猜你想从这个指标中自动获取信号。对此有一个简单的解决方案。该指标被声明为有7个缓冲区(#属性 indicator_buffers 7),但它只使用了5个。 指标最多可使用8个缓冲区。这意味着你可以为你的计算声明另一个额外的缓冲区,并用信息标识来填充它。你可以在TextOutput函数中找到信息编号。简单地将数字添加到缓冲区,这取决于显示的信息。例如,如果文本是:"UPTHRUST / Weakness_",那么就在缓冲区里加1,如果信息是PSEUDO UPTHRUST / Weakness_,就加4,以此类推。缓冲区的索引将与 "i "变量的值相同。
至于你的第二个问题:你总是可以对一个指标(而不是脚本)使用iCustom函数,如果它填补了指标中声明的缓冲区,就可以读取其值。例如,如果这将是一个画线的指标,那么你可以读取线的值 - 因为要画一些东西(除了标签),指标必须填充缓冲区。如果该指标将创建图形对象(像你所附的那个),那么你将需要:a)从图形对象中读取数值,或者b)重新编码指标(像我上面建议的那样)。指标是否使用DLL并不重要--它只需要正确填充缓冲区,以便从iCustom函数中读取数值。
日子
我在EA上有一个时间过滤器,但我一直想给它附加一个平仓功能,如果时间等于收盘时间,那么平仓。
extern int gmtshift=1; // gmt offset of the broker
extern bool generalfilter=false; // enable time filter
extern int starthour=7; // start hour to trade after this hour
extern int startminutes=0; // minutes of the start hour
extern int endhour=21; // stop to trade after this hour
extern int endminutes=0; // minutes of the start hour
extern bool tradesunday=true; // trade on sunday
extern bool fridayfilter=false; // enable special time filter on friday
extern int fridayhour=21; // stop to trade after this hour
extern int fridayminutes=0; // minutes of the friday hour[/CODE]
[CODE]void start() {
if(generalfilter){
nstarthour=starthour+(gmtshift);if(nstarthour>23)nstarthour=nstarthour-24;
if(nstarthour<10)istarthour="0"+nstarthour;
if(nstarthour>9)istarthour=nstarthour;
if(startminutes<10)istartminutes="0"+startminutes;
if(startminutes>9)istartminutes=startminutes;
tstart=StrToTime(istarthour+":"+istartminutes);
nendhour=endhour+(gmtshift);if(nendhour>23)nendhour=nendhour-24;
if(endhour<10)iendhour="0"+nendhour;
if(endhour>9)iendhour=nendhour;
if(endminutes<10)iendminutes="0"+endminutes;
if(endminutes>9)iendminutes=endminutes;
tend=StrToTime(iendhour+":"+iendminutes);
}
if(fridayfilter){
nfridayhour=fridayhour+(gmtshift);if(nfridayhour>23)nfridayhour=nfridayhour-24;
if(nfridayhour<10)ifridayhour="0"+nfridayhour;
if(nfridayhour>9)ifridayhour=nfridayhour;
if(fridayminutes<10)ifridayminutes="0"+fridayminutes;
if(fridayminutes>9)ifridayminutes=fridayminutes;
tfriday=StrToTime(ifridayhour+":"+ifridayminutes);
}
if((generalfilter && (nstarthour<nendhour && TimeCurrent()tend) || (nstarthour>nendhour && TimeCurrent()tend))
|| (tradesunday==false && DayOfWeek()==0) || (fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday))return(0);
if (TimeCurrent() >= tend) {
for (int i=OrdersTotal()-1; i>=0; i--) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==TradeSymbol) {
if (OrderType()==OP_BUY) {
pBid=MarketInfo(OrderSymbol(), MODE_BID);
OrderClose(OrderTicket(), OrderLots(), Bid, slippage, Yellow);
}
if (OrderType()==OP_SELL) {
pAsk=MarketInfo(OrderSymbol(), MODE_ASK);
OrderClose(OrderTicket(), OrderLots(), Ask, slippage, Orange);
}
}
}
}
}试着检查一下 这部分。
if((generalfilter && (nstarthour<nendhour && TimeCurrent()tend) || (nstarthour>nendhour && TimeCurrent()tend))
|| ( tradesunday==false && DayOfWeek()==0)|| (fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday))返回(0)。
代码的其他部分可能更简单,但它应该是有效的。
然而,如果你在关闭所有部分之前退出脚本,那么它就不会工作,而且似乎脚本正在这样做。
请看一下这部分的例子。
(fridayfilter && DayOfWeek()==5 && TimeCurrent()>tfriday) return(0)。
英文的意思是:如果是星期五,并且星期五过滤器是打开的,并且时间标记已经通过(例如,结束时间是18.00,现在是18.01),那么返回(0)。
它应该是:如果它是星期五,并且星期五过滤器是开着的,并且时间标记是通过关闭所有和(例如,结束时间是18.00和它是18.01)然后返回(0)。