编码帮助 - 页 212 1...205206207208209210211212213214215216217218219...786 新评论 Mladen Rakic 2013.12.23 19:35 #2111 zoroxzyad: 我可以使用lwma,所以如果我想让周期为30天,我应该在图表中放入什么mv,两个ma或只是一个有多少周期,我不擅长数学,非常非常非常感谢你的努力。 zoroxzyad 你不能只使用移动平均线。你必须使用之前帖子中的公式 techmac 2013.12.23 21:25 #2112 有新的metatrader 4的手册吗? 或者他们会不会做一个? Mladen Rakic 2013.12.24 07:19 #2113 techmac: 有新的metatrader 4的手册吗? 或者他们会不会做一个? 据我所知,没有。我想一定会有的(在发展的某个阶段)。 michaelB 2013.12.29 05:27 #2114 Mladen,附上你修改的指标,以便在主图上显示交叉信号。 arrUp[CB] = EMPTY_VALUE; arrDn[CB] = EMPTY_VALUE; state[CB] = state[CB+1]; if (TrendBuffer[CB]>LoBuffer[CB]) state[CB] = 1; if (TrendBuffer[CB]<LoBuffer[CB]) state[CB] = -1; if (state[CB]!=state[CB+1]) { if (state[CB]== 1) arrUp[CB] = Low[CB] -iATR(NULL,0,10,CB)/2.0; if (state[CB]==-1) arrDn[CB] = High[CB]+iATR(NULL,0,10,CB)/2.0; } 有没有一种简单的方法来解释这段代码是如何插入信号的? 谢谢你。 附加的文件: 5_34_5_on_chart_v02.mq4 4 kb Mladen Rakic 2013.12.29 06:49 #2115 michaelB: Mladen, 附上一个你修改过的指标,在主图上显示交叉信号。 arrUp[CB] = EMPTY_VALUE; arrDn[CB] = EMPTY_VALUE; state[CB] = state[CB+1]; if (TrendBuffer[CB]>LoBuffer[CB]) state[CB] = 1; if (TrendBuffer[CB]<LoBuffer[CB]) state[CB] = -1; if (state[CB]!=state[CB+1]) { if (state[CB]== 1) arrUp[CB] = Low[CB] -iATR(NULL,0,10,CB)/2.0; if (state[CB]==-1) arrDn[CB] = High[CB]+iATR(NULL,0,10,CB)/2.0; } 有没有一种简单的方法来解释这段代码是如何插入信号的? 谢谢你。 迈克尔 它是在两个缓冲区:TrendBuffer和LoBuffer中寻找一个交叉值。它标记这两个缓冲区的当前状态:如果TrendBuffer>LoBuffer,它将状态设置为1;如果TrendBuffer<LoBuffer,它将状态设置为-1。 现在,当当前柱状体的状态与前一个柱状体的状态不同时,意味着有一个交叉点。然后它在图表上画出一个箭头 [删除] 2013.12.29 11:17 #2116 又麻烦老师了,请把这个指标转换为MT4指标,谢谢! colorbars_hlc.mq5 附加的文件: colorbars_hlc.mq5 4 kb michaelB 2013.12.29 15:12 #2117 mladen: 迈克尔 它在两个缓冲区:TrendBuffer和LoBuffer中寻找一个交叉的值。它标记这两个缓冲区的当前状态:如果TrendBuffer>LoBuffer,它将状态设置为1;如果TrendBuffer<LoBuffer,它将状态设置为-1。 现在,当当前柱状体的状态与前一个柱状体的状态不同时,意味着有一个交叉。然后它在图表上画出一个箭头 好的,这解释了TrendBuffer和LoBuffer。 但是arrUp和arrDn是如何工作的? 为什么信号会出现 在某些蜡烛上,而不是每支蜡烛。 再次感谢。 Mladen Rakic 2013.12.29 15:27 #2118 michaelB: 好了,这解释了TrendBuffer和LoBuffer。但是arrUp和arrDn是如何工作的?为什么信号会出现在某些蜡烛上,而不是每根蜡烛。 再次感谢。 michael 想象一下这样一个序列(当TrendBuffer>LoBuffer时为1,TrendBuffer<LoBuffer时为-1) 11111111-1-1-1-1-1-1-1-111111111 只有当1变成-1或-1变成1时(当 "状态 "改变时),才需要画箭头。这就是为什么有一行在检查(这一行:如果(state[CB] !=state[CB+1]))。所以,当状态发生变化时,就会画出箭头,否则就根本不需要画出箭头。 arroganztrader 2013.12.29 22:22 #2119 嘿,mladen。 希望你在接近年底的时候有时间。 下面的代码与我上次问的问题有关。它在一个订单中跟踪了0.8个点,而目标是2个点的增加。 但我怎样才能改变它,使它检查 所有的订单并单独跟踪它们? 非常感谢您!您在这里所做的工作非常好。你在这里做的工作很棒。 int start() { //---- if (OrdersTotal() == 0) { isStopLoss = false; } for(int i=0; i<=OrdersTotal(); i++) { if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { continue; } if(OrdersTotal() == 0) { continue; } OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(isStopLoss == true) { if(OrderType() == OP_BUY) { if(iClose(Symbol(), 0, 0) >= (OrderOpenPrice()+inProfitStopLoss*Point)) { // Zieht bei 2.0 Pips nach! - 200 = 2.0 Pips if(isTrailing == true) { if(iClose(Symbol(), 0, 0) >= (lastStopLoss+trailingStop)) { OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss+trailingStop), 0,0,0); lastStopLoss = OrderStopLoss(); //isTrailing = true; continue; } } OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+inProfitStopLoss*Point,0,0,0); if(OrderStopLoss() >= OrderOpenPrice()) { isTrailing = true; } lastStopLoss = OrderStopLoss(); } } else if(OrderType() == OP_SELL) { if(iClose(Symbol(), 0, 0) <= (OrderOpenPrice()-inProfitStopLoss*Point)) { if(isTrailing == true) { if(iClose(Symbol(), 0, 0) <= (lastStopLoss-trailingStop)) { OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss-trailingStop), 0,0,0); lastStopLoss = OrderStopLoss(); //isTrailing = true; continue; } } OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-inProfitStopLoss*Point,0,0,0); // 200 ursprünglich if(OrderStopLoss() <= OrderOpenPrice()) { isTrailing = true; } lastStopLoss = OrderStopLoss(); } } lastStopLoss = OrderStopLoss(); continue; } if(OrderType() == OP_BUY) { isStopLoss = true; OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-initialStopLoss*Point,0,0,0); } else if(OrderType() == OP_SELL) { isStopLoss = true; OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+initialStopLoss*Point,0,0,0); } lastStopLoss = OrderStopLoss(); } //---- return(0); } Coding help 任何菜鸟问题,为了不给论坛添乱。专业人士,不要路过。没有你就无处可去 - 6. 退出策略。阶梯式止损与拖曳式止损 Mladen Rakic 2013.12.30 07:36 #2120 arroganzmaschine: 嘿,mladen。希望你在接近年底的时候有时间。 下面的代码与我上次问到的问题有关系。它在一个订单中跟踪了0.8个点,而目标是2个点。 但我怎样才能改变它,使它检查所有的订单并单独跟踪它们? 非常感谢您!您在这里所做的工作非常好。你在这里做的工作很棒。 int start() { //---- if (OrdersTotal() == 0) { isStopLoss = false; } for(int i=0; i<=OrdersTotal(); i++) { if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) { continue; } if(OrdersTotal() == 0) { continue; } OrderSelect(i, SELECT_BY_POS, MODE_TRADES); if(isStopLoss == true) { if(OrderType() == OP_BUY) { if(iClose(Symbol(), 0, 0) >= (OrderOpenPrice()+inProfitStopLoss*Point)) { // Zieht bei 2.0 Pips nach! - 200 = 2.0 Pips if(isTrailing == true) { if(iClose(Symbol(), 0, 0) >= (lastStopLoss+trailingStop)) { OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss+trailingStop), 0,0,0); lastStopLoss = OrderStopLoss(); //isTrailing = true; continue; } } OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+inProfitStopLoss*Point,0,0,0); if(OrderStopLoss() >= OrderOpenPrice()) { isTrailing = true; } lastStopLoss = OrderStopLoss(); } } else if(OrderType() == OP_SELL) { if(iClose(Symbol(), 0, 0) <= (OrderOpenPrice()-inProfitStopLoss*Point)) { if(isTrailing == true) { if(iClose(Symbol(), 0, 0) <= (lastStopLoss-trailingStop)) { OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss-trailingStop), 0,0,0); lastStopLoss = OrderStopLoss(); //isTrailing = true; continue; } } OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-inProfitStopLoss*Point,0,0,0); // 200 ursprünglich if(OrderStopLoss() <= OrderOpenPrice()) { isTrailing = true; } lastStopLoss = OrderStopLoss(); } } lastStopLoss = OrderStopLoss(); continue; } if(OrderType() == OP_BUY) { isStopLoss = true; OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-initialStopLoss*Point,0,0,0); } else if(OrderType() == OP_SELL) { isStopLoss = true; OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+initialStopLoss*Point,0,0,0); } lastStopLoss = OrderStopLoss(); } //---- return(0); } 尊敬的先生 请查看这个帖子中的EA管理跟踪止损的方式:https://www.mql5.com/en/forum/181334。我认为它可以帮助你,因为它有处理跟踪止损所需的所有元素(包括错误检查)。 1...205206207208209210211212213214215216217218219...786 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
我可以使用lwma,所以如果我想让周期为30天,我应该在图表中放入什么mv,两个ma或只是一个有多少周期,我不擅长数学,非常非常非常感谢你的努力。
zoroxzyad
你不能只使用移动平均线。你必须使用之前帖子中的公式
有新的metatrader 4的手册吗?
或者他们会不会做一个?
有新的metatrader 4的手册吗? 或者他们会不会做一个?
据我所知,没有。我想一定会有的(在发展的某个阶段)。
Mladen,附上你修改的指标,以便在主图上显示交叉信号。
arrDn[CB] = EMPTY_VALUE;
state[CB] = state[CB+1];
if (TrendBuffer[CB]>LoBuffer[CB]) state[CB] = 1;
if (TrendBuffer[CB]<LoBuffer[CB]) state[CB] = -1;
if (state[CB]!=state[CB+1])
{
if (state[CB]== 1) arrUp[CB] = Low[CB] -iATR(NULL,0,10,CB)/2.0;
if (state[CB]==-1) arrDn[CB] = High[CB]+iATR(NULL,0,10,CB)/2.0;
}有没有一种简单的方法来解释这段代码是如何插入信号的?
谢谢你。
Mladen, 附上一个你修改过的指标,在主图上显示交叉信号。
arrDn[CB] = EMPTY_VALUE;
state[CB] = state[CB+1];
if (TrendBuffer[CB]>LoBuffer[CB]) state[CB] = 1;
if (TrendBuffer[CB]<LoBuffer[CB]) state[CB] = -1;
if (state[CB]!=state[CB+1])
{
if (state[CB]== 1) arrUp[CB] = Low[CB] -iATR(NULL,0,10,CB)/2.0;
if (state[CB]==-1) arrDn[CB] = High[CB]+iATR(NULL,0,10,CB)/2.0;
}有没有一种简单的方法来解释这段代码是如何插入信号的?
谢谢你。迈克尔
它是在两个缓冲区:TrendBuffer和LoBuffer中寻找一个交叉值。它标记这两个缓冲区的当前状态:如果TrendBuffer>LoBuffer,它将状态设置为1;如果TrendBuffer<LoBuffer,它将状态设置为-1。
现在,当当前柱状体的状态与前一个柱状体的状态不同时,意味着有一个交叉点。然后它在图表上画出一个箭头
又麻烦老师了,请把这个指标转换为MT4指标,谢谢!
colorbars_hlc.mq5
迈克尔
它在两个缓冲区:TrendBuffer和LoBuffer中寻找一个交叉的值。它标记这两个缓冲区的当前状态:如果TrendBuffer>LoBuffer,它将状态设置为1;如果TrendBuffer<LoBuffer,它将状态设置为-1。
现在,当当前柱状体的状态与前一个柱状体的状态不同时,意味着有一个交叉。然后它在图表上画出一个箭头好的,这解释了TrendBuffer和LoBuffer。
但是arrUp和arrDn是如何工作的?
为什么信号会出现 在某些蜡烛上,而不是每支蜡烛。
再次感谢。
好了,这解释了TrendBuffer和LoBuffer。
但是arrUp和arrDn是如何工作的?
为什么信号会出现在某些蜡烛上,而不是每根蜡烛。
再次感谢。michael
想象一下这样一个序列(当TrendBuffer>LoBuffer时为1,TrendBuffer<LoBuffer时为-1)
11111111-1-1-1-1-1-1-1-111111111
只有当1变成-1或-1变成1时(当 "状态 "改变时),才需要画箭头。这就是为什么有一行在检查(这一行:如果(state[CB] !=state[CB+1]))。所以,当状态发生变化时,就会画出箭头,否则就根本不需要画出箭头。
嘿,mladen。
希望你在接近年底的时候有时间。
下面的代码与我上次问的问题有关。它在一个订单中跟踪了0.8个点,而目标是2个点的增加。
但我怎样才能改变它,使它检查 所有的订单并单独跟踪它们?
非常感谢您!您在这里所做的工作非常好。你在这里做的工作很棒。
int start()
{
//----
if (OrdersTotal() == 0) {
isStopLoss = false;
}
for(int i=0; i<=OrdersTotal(); i++) {
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
continue;
}
if(OrdersTotal() == 0) {
continue;
}
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(isStopLoss == true) {
if(OrderType() == OP_BUY) {
if(iClose(Symbol(), 0, 0) >= (OrderOpenPrice()+inProfitStopLoss*Point)) { // Zieht bei 2.0 Pips nach! - 200 = 2.0 Pips
if(isTrailing == true) {
if(iClose(Symbol(), 0, 0) >= (lastStopLoss+trailingStop)) {
OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss+trailingStop), 0,0,0);
lastStopLoss = OrderStopLoss();
//isTrailing = true;
continue;
}
}
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+inProfitStopLoss*Point,0,0,0);
if(OrderStopLoss() >= OrderOpenPrice()) {
isTrailing = true;
}
lastStopLoss = OrderStopLoss();
}
} else if(OrderType() == OP_SELL) {
if(iClose(Symbol(), 0, 0) <= (OrderOpenPrice()-inProfitStopLoss*Point)) {
if(isTrailing == true) {
if(iClose(Symbol(), 0, 0) <= (lastStopLoss-trailingStop)) {
OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss-trailingStop), 0,0,0);
lastStopLoss = OrderStopLoss();
//isTrailing = true;
continue;
}
}
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-inProfitStopLoss*Point,0,0,0); // 200 ursprünglich
if(OrderStopLoss() <= OrderOpenPrice()) {
isTrailing = true;
}
lastStopLoss = OrderStopLoss();
}
}
lastStopLoss = OrderStopLoss();
continue;
}
if(OrderType() == OP_BUY) {
isStopLoss = true;
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-initialStopLoss*Point,0,0,0);
} else if(OrderType() == OP_SELL) {
isStopLoss = true;
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+initialStopLoss*Point,0,0,0);
}
lastStopLoss = OrderStopLoss();
}
//----
return(0);
}嘿,mladen。
希望你在接近年底的时候有时间。
下面的代码与我上次问到的问题有关系。它在一个订单中跟踪了0.8个点,而目标是2个点。
但我怎样才能改变它,使它检查所有的订单并单独跟踪它们?
非常感谢您!您在这里所做的工作非常好。你在这里做的工作很棒。
int start()
{
//----
if (OrdersTotal() == 0) {
isStopLoss = false;
}
for(int i=0; i<=OrdersTotal(); i++) {
if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) {
continue;
}
if(OrdersTotal() == 0) {
continue;
}
OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
if(isStopLoss == true) {
if(OrderType() == OP_BUY) {
if(iClose(Symbol(), 0, 0) >= (OrderOpenPrice()+inProfitStopLoss*Point)) { // Zieht bei 2.0 Pips nach! - 200 = 2.0 Pips
if(isTrailing == true) {
if(iClose(Symbol(), 0, 0) >= (lastStopLoss+trailingStop)) {
OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss+trailingStop), 0,0,0);
lastStopLoss = OrderStopLoss();
//isTrailing = true;
continue;
}
}
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+inProfitStopLoss*Point,0,0,0);
if(OrderStopLoss() >= OrderOpenPrice()) {
isTrailing = true;
}
lastStopLoss = OrderStopLoss();
}
} else if(OrderType() == OP_SELL) {
if(iClose(Symbol(), 0, 0) <= (OrderOpenPrice()-inProfitStopLoss*Point)) {
if(isTrailing == true) {
if(iClose(Symbol(), 0, 0) <= (lastStopLoss-trailingStop)) {
OrderModify(OrderTicket(), OrderOpenPrice(), (lastStopLoss-trailingStop), 0,0,0);
lastStopLoss = OrderStopLoss();
//isTrailing = true;
continue;
}
}
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-inProfitStopLoss*Point,0,0,0); // 200 ursprünglich
if(OrderStopLoss() <= OrderOpenPrice()) {
isTrailing = true;
}
lastStopLoss = OrderStopLoss();
}
}
lastStopLoss = OrderStopLoss();
continue;
}
if(OrderType() == OP_BUY) {
isStopLoss = true;
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-initialStopLoss*Point,0,0,0);
} else if(OrderType() == OP_SELL) {
isStopLoss = true;
OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+initialStopLoss*Point,0,0,0);
}
lastStopLoss = OrderStopLoss();
}
//----
return(0);
}尊敬的先生
请查看这个帖子中的EA管理跟踪止损的方式:https://www.mql5.com/en/forum/181334。我认为它可以帮助你,因为它有处理跟踪止损所需的所有元素(包括错误检查)。