编码帮助......我如何让指标过滤而不是警报? - 页 5

 

订单被放在离当前买入/卖出价太近的位置。订单需要离当前价格有一定的距离。使用Marketinfo函数 和Stop_level参数来提取该信息,并确保你的订单离卖出价/买入价有一定的距离。

希望这有帮助。

 
Maji:
订单被放在离当前买入/卖出价太近的地方。订单需要离当前价格有一定的距离。使用Marketinfo功能和Stop_level参数来提取该信息,并确保你的订单离卖出价/买入价有那么远。 希望这能帮助你。

ummm....

对不起,你把我弄糊涂了。

我不能在 "当前 "水平下单吗?我在这一点上所做的大部分工作都是在收盘时执行订单。这可以做到吗?

我必须先了解什么是止损位参数和市场信息功能。

谢谢你的指导

不管怎么样,这是我对趋势带指标所做的更新,这很有趣

好了,这里是...

市场信息 标识符,与MarketInfo()函数一起使用。

它可以是以下任何一个值。

MODE_STOPLEVEL 14 停损水平,单位为点。

所以我认为它是...

MarketInfo(14)

我应该把它放在哪里?

或者是...

MarketInfo(NULL,MODE_STOPLEVEL)。

或...

double bid =MarketInfo(NULL,MODE_BID);

double ask =MarketInfo(NULL,MODE_ASK);

double point =MarketInfo(NULL,MODE_POINT);

我想我不太明白如何使用这个......你能给我一个例子吗?

这就是我在这种情况下的工作......我想知道为什么这个EA以前没有下单的问题,现在却有了?在我添加过滤器之前,它是有效的?

//----------channel filter

double upLevel = iCustom(NULL,TF, "Trend Bands v3", back, bandwidth, 0, 0);

double LowLevel = iCustom(NULL,TF, "Trend Bands v3", back, bandwidth, 2, 0);

// ENTRY

if(total < 2 || isNewSumbol(Symbol())) //I have modified the if condition too: it was total<1 (orBanAway aka cucurucu)

{

double HedgeLots = (HedgePercent/100)*Lots; //calculates the Lots for the hedged position

if(isCrossed == 1 && Ask < upLevel)

{

if(UseStopLoss)

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);

else

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,0,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

//###################################################################### the added code starts here

if(UseStopLoss)

ticket=OrderSend(Symbol(),OP_SELL,HedgeLots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,comment,MAGICMA,0,Red);

else

ticket=OrderSend(Symbol(),OP_SELL,HedgeLots,Bid,3,0,Bid-TakeProfit*Point,comment,MAGICMA,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

//###################################################################### ends here

return(0);

}

if(isCrossed == 2 && Ask > LowLevel)

{

if(UseStopLoss)

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,comment,MAGICMA,0,Red);

else

ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,0,Bid-TakeProfit*Point,comment,MAGICMA,0,Red);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("SELL order opened : ",OrderOpenPrice());

}

else Print("Error opening SELL order : ",GetLastError());

//###################################################################### the added code starts here

if(UseStopLoss)

ticket=OrderSend(Symbol(),OP_BUY,HedgeLots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);

else

ticket=OrderSend(Symbol(),OP_BUY,HedgeLots,Ask,3,0,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);

if(ticket>0)

{

if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES)) Print("BUY order opened : ",OrderOpenPrice());

}

else Print("Error opening BUY order : ",GetLastError());

//###################################################################### ends here

return(0);

}

return(0);

}

return(0);

}

return(0);

}

}

//+------------------------------------------------------------------+
附加的文件:
 

你应该使用MarketInfo(NULL,MODE_STOPLEVEL)来确定你的止损单 应该离当前价格多远。请记住,它将以点为单位返回其值。

然而,你可以通过使用类似的方法转换为点数。

double MinDist = NormalizeDouble(MarketInfo(NULL,MODE_STOPLEVEL)*Point, Digits);

现在确保你的止损单离当前市场价格至少有那么远。顺便说一下,通过使用NormalizeDouble和Digits,你正在将点值转换到小数点后的适当位置(4或2)。这是MT4的一个非常好的东西。

希望这有帮助。

马吉

 
Maji:
你应该使用MarketInfo(NULL,MODE_STOPLEVEL)来确定你的止损单应该离当前价格多远。请记住,它将以点为单位返回其值。

然而,你可以通过使用这样的方法转换为点数。

double MinDist = NormalizeDouble(MarketInfo(NULL,MODE_STOPLEVEL)*Point, Digits);

现在确保你的止损单离当前市场价格至少有那么远。顺便说一下,通过使用NormalizeDouble和Digits,你正在将点值转换到小数点后的适当位置(4或2)。这是MT4的一个非常好的东西。

希望这有帮助。

马吉

我不明白的是,为什么把指标作为一个过滤器加入到它的下单或止损方式中去了。据我所知,它并没有改变任何东西,那么为什么不允许高于线的交易会改变它下达止损单 的方式?

 

如果你不介意,请把当前的代码发到我的邮箱。我将尝试在周末看一下。我不能保证一定能修好它,但会诚实地看看并尝试。

 

这是你应该先看的问题

if(isCrossed == 1 && Ask < upLevel-longrange)[/PHP]

Ask and upLevel are in "price" (like 115.56 or 1.2678) while longrange is in pips (like 4,5,6) and u cannot mixed them. U have to normalize the pips to "price" and this is done by muliplying the pips with Points

the corrected code is like that

[PHP]if(isCrossed == 1 && Ask < upLevel-longrange*Point)
 

这一次,这是一个简单的解决方案......

只是...

......事情是,自从我发了那个帖子后,我改变了它。 ...我用一个参数修改了指标,使波段变宽或变窄,并去掉了EA中与线相近的部分。我想,如果我可以让交易波段本身变窄或变宽,就会有同样的功能,而不会那么复杂,而且对我来说,更容易保持心理跟踪....so...

目前它是这样的...

//----------channel filter

double upLevel = iCustom(NULL,TF, "Trend Bands v3", back, bandwidth, 0, 0);

double LowLevel = iCustom(NULL,TF, "Trend Bands v3", back, bandwidth, 2, 0);

// ENTRY

if(total < 2 || isNewSumbol(Symbol())) //I have modified the if condition too: it was total<1 (orBanAway aka cucurucu)

{

double HedgeLots = (HedgePercent/100)*Lots; //calculates the Lots for the hedged position

if(isCrossed == 1 && Ask < upLevel)

{

if(UseStopLoss)

ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,comment,MAGICMA,0,Green);

else

这是仍在产生错误的代码。一定有更多的事情发生。

 

到目前为止,我还没有看到任何问题(面向代码)。

但从逻辑上看,请看这个

if(isCrossed == 1 && Ask < upLevel)

你不是在检查 它们是否接近,只是在检查价格是否低于该线

 

我就知道我有!!!我测试的正是你想要的东西。

我测试的正是你想得到的东西,而我之前的帖子只是放错了EA。

这个EA最多可以检查 4个TF,以检查它们是否同时得到边缘。如果你想,你可以只选择一个。

你可以把它作为一个例子,说明如何从一个指标中获得逻辑,以及如何把多个TF结合在一起。

问候

伊莱

附加的文件:
tbs.mq4  7 kb
 
elihayun:
我就知道我有这个能力!!!。

我测试的正是你想得到的东西,而我之前的帖子只是放错了EA。

这个EA最多可以检查4个TF,以检查它们是否同时得到边缘。如果你想,你可以只选择一个。

你可以把它作为一个例子,说明如何从一个指标中获得逻辑,以及如何把多个TF结合在一起。

问候

伊莱

这是耐人寻味的 ,我还没有真正接触过多TF指标,但我相信它们是有优点的。