编码帮助 - 页 212

 
zoroxzyad:
我可以使用lwma,所以如果我想让周期为30天,我应该在图表中放入什么mv,两个ma或只是一个有多少周期,我不擅长数学,非常非常非常感谢你的努力。

zoroxzyad

你不能只使用移动平均线。你必须使用之前帖子中的公式

 

有新的metatrader 4的手册吗?

或者他们会不会做一个?

 
techmac:
有新的metatrader 4的手册吗? 或者他们会不会做一个?

据我所知,没有。我想一定会有的(在发展的某个阶段)。

 

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;

}

有没有一种简单的方法来解释这段代码是如何插入信号的?

谢谢你。

附加的文件:
 
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。

现在,当当前柱状体的状态与前一个柱状体的状态不同时,意味着有一个交叉点。然后它在图表上画出一个箭头

 

又麻烦老师了,请把这个指标转换为MT4指标,谢谢!

colorbars_hlc.mq5

附加的文件:
 
mladen:
迈克尔

它在两个缓冲区:TrendBuffer和LoBuffer中寻找一个交叉的值。它标记这两个缓冲区的当前状态:如果TrendBuffer>LoBuffer,它将状态设置为1;如果TrendBuffer<LoBuffer,它将状态设置为-1。

现在,当当前柱状体的状态与前一个柱状体的状态不同时,意味着有一个交叉。然后它在图表上画出一个箭头

好的,这解释了TrendBuffer和LoBuffer。

但是arrUp和arrDn是如何工作的?

为什么信号会出现 在某些蜡烛上,而不是每支蜡烛。

再次感谢。

 
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]))。所以,当状态发生变化时,就会画出箭头,否则就根本不需要画出箭头。

 

嘿,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);

}
 
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。我认为它可以帮助你,因为它有处理跟踪止损所需的所有元素(包括错误检查)。