//+------------------------------------------------------------------+ //| Signal Exit Buy / Exit Sell) //| Iterate through open tickets //+------------------------------------------------------------------+
//+------------------------------------------------------------------+ //| Signal Exit Buy / Exit Sell) //| Iterate through open tickets //+------------------------------------------------------------------+
//+-------------------------------------------------------------------------+ //| Signal close Buy / close Sell / Open new BUY or SELL order when possible
int PositionIndex; int TotalNumberOfOrders; TotalNumberOfOrders = OrdersTotal();// store number of Orders in the variable
for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)// for loop to loop through all Orders . . COUNT DOWN TO ZERO ! { if(!OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES)) continue;// if the OrderSelect fails advance the loop to the next PositionIndex
if(OrderMagicNumber() == MagicNumber // does the Order's Magic Number match our EA's magic number ? && OrderSymbol() == Symbol() // does the Order's Symbol match the Symbol our EA is working on ? && (OrderType() == OP_BUY// is the Order a Buy Order ? || OrderType() == OP_SELL )) // or is it a Sell Order ?
if (! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage*PipMultiplier,DarkOrange )) //try to close the order Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError()); //if the Order Close failed print some helpful information
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>52) // Check if new entry condition is given { OpenBuy_=true; } else if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<42) { OpenSell_=true; } } // end of For loop
//+-------------------------------------------------------------------------+ //| Signal close Buy / close Sell / Open new BUY or SELL order when possible
int PositionIndex; int TotalNumberOfOrders; TotalNumberOfOrders = OrdersTotal();// store number of Orders in the variable
for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)// for loop to loop through all Orders . . COUNT DOWN TO ZERO ! { if(!OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES)) continue;// if the OrderSelect fails advance the loop to the next PositionIndex
if(OrderMagicNumber() == MagicNumber // does the Order's Magic Number match our EA's magic number ? && OrderSymbol() == Symbol() // does the Order's Symbol match the Symbol our EA is working on ? && (OrderType() == OP_BUY// is the Order a Buy Order ? || OrderType() == OP_SELL )) // or is it a Sell Order ?
if (! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage*PipMultiplier,DarkOrange )) //try to close the order Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError()); //if the Order Close failed print some helpful information
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>52) // Check if new entry condition is given { OpenBuy_=true; } else if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<42) { OpenSell_=true; } } // end of For loop
Here is the EA for B& S with 15 warnings left. If some one could tell me how to clear Declaration of global such as “declaration of 'trailingprofit' hides global declaration at line 62 mnt-BuyersSellers EA v1.00.mq4 915 53” I will clear it up.
I also need a few files to run it.
2016.12.17 16:01:35.347 2016.11.01 00:47 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\4BARS-MTF-BBH 1.06.ex4' [2]
2016.12.17 16:01:29.815 2016.11.01 00:17 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\BullBearHelper 1.00.ex4' [2]
2016.12.17 16:01:29.815 2016.11.01 00:17 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\AdaptiveLaguerreFilter.ex4' [2]
Hi Pro-Coders,
我想知道是否有人能提供帮助。
我想让我的EA在趋势变化时打开一个买入交易并关闭一个现有的卖出交易。
它做到了,但只是在它获利的时候。当趋势发生变化而头寸仍在
时,它就会在StopLoss中运行。(见图片)。它有时工作,有时不工作。
我应该如何改进?
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>55)
{
OpenBuy_ =true;
CloseSell_=true;
}
else
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<45)
{
OpenSell_=true;
CloseBuy_=true;
}
这段代码还不足以得出任何结论
嗨,Mladen。
非常感谢您对我的问题的关注。
请看下面的代码,它将关闭现有的卖单和买单。
如果趋势指向正确的方向,它也应该打开一个新的买入或卖出订单...
//+------------------------------------------------------------------+
//| Signal Exit Buy / Exit Sell)
//| Iterate through open tickets
//+------------------------------------------------------------------+
for(int i=0; i<Total; i++)
{
dummyResult=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber)
{
for(int z=OrdersTotal()-1; z>=0; z--)
{
if(OrderSelect(z,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
buy_ticket=OrderTicket();
else
if(OrderType()== OP_SELL)
sell_ticket=OrderTicket();
}
// Close BUY
if(CloseBuy_==true && buy_ticket!=0)
{
dummyResult=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage*PipMultiplier,MediumSeaGreen);
if(EachTickMode) TickCheck = True;
if(!EachTickMode) BarCount = Bars;
Print("Error closing Buy #",(string)OrderTicket()," Error code ",(string)GetLastError());
// Open new Sell Order
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<45) OpenSell_=true;
}
// Close SELL
if(CloseSell_==true && sell_ticket!=0)
{
dummyResult=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage*PipMultiplier,DarkOrange);
if(EachTickMode) TickCheck = True;
if(!EachTickMode) BarCount = Bars;
Print("Error closing Sell #",(string)OrderTicket()," Error code ",(string)GetLastError());
// Open new Buy Order
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>55) OpenBuy_ =true;
}
嗨,Mladen。
非常感谢您对我的问题的关注。
请看下面的代码,它将关闭现有的卖单和买单。
如果趋势指向正确的方向,它也应该打开一个新的买入或卖出订单...
//+------------------------------------------------------------------+
//| Signal Exit Buy / Exit Sell)
//| Iterate through open tickets
//+------------------------------------------------------------------+
for(int i=0; i<Total; i++)
{
dummyResult=OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY && OrderMagicNumber()==MagicNumber)
{
for(int z=OrdersTotal()-1; z>=0; z--)
{
if(OrderSelect(z,SELECT_BY_POS,MODE_TRADES) && OrderMagicNumber()==MagicNumber && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY)
buy_ticket=OrderTicket();
else
if(OrderType()== OP_SELL)
sell_ticket=OrderTicket();
}
// Close BUY
if(CloseBuy_==true && buy_ticket!=0)
{
dummyResult=OrderClose(OrderTicket(),OrderLots(),Bid,Slippage*PipMultiplier,MediumSeaGreen);
if(EachTickMode) TickCheck = True;
if(!EachTickMode) BarCount = Bars;
Print("Error closing Buy #",(string)OrderTicket()," Error code ",(string)GetLastError());
// Open new Sell Order
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<45) OpenSell_=true;
}
// Close SELL
if(CloseSell_==true && sell_ticket!=0)
{
dummyResult=OrderClose(OrderTicket(),OrderLots(),Ask,Slippage*PipMultiplier,DarkOrange);
if(EachTickMode) TickCheck = True;
if(!EachTickMode) BarCount = Bars;
Print("Error closing Sell #",(string)OrderTicket()," Error code ",(string)GetLastError());
// Open new Buy Order
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>55) OpenBuy_ =true;
}
你为什么要在循环中使用循环?根本不需要。把它去掉,当代码简化后,所有的东西也会更容易清理。
你好,Mladen。
我对代码进行了相应的修改,您认为现在的代码更好了吗?
能否请您看一下?这段代码还处于伪装状态,还没有测试。
先谢谢你了!
//+-------------------------------------------------------------------------+
int PositionIndex;//| Signal close Buy / close Sell / Open new BUY or SELL order when possible
int TotalNumberOfOrders;
TotalNumberOfOrders = OrdersTotal();// store number of Orders in the variable
for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)// for loop to loop through all Orders . . COUNT DOWN TO ZERO !
{
if(!OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES)) continue;// if the OrderSelect fails advance the loop to the next PositionIndex
if(OrderMagicNumber() == MagicNumber // does the Order's Magic Number match our EA's magic number ?
&& OrderSymbol() == Symbol() // does the Order's Symbol match the Symbol our EA is working on ?
&& (OrderType() == OP_BUY // is the Order a Buy Order ?
|| OrderType() == OP_SELL )) // or is it a Sell Order ?
if (! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage*PipMultiplier,DarkOrange )) //try to close the order
Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError()); //if the Order Close failed print some helpful information
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>52) // Check if new entry condition is given
{
OpenBuy_=true;
}
else
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<42)
{
OpenSell_=true;
}
} // end of For loop
你好,Mladen。
我对代码进行了相应的修改,您认为现在的代码更好了吗?
能否请您看一下?这段代码还处于伪装状态,还没有测试。
先谢谢你了!
//+-------------------------------------------------------------------------+
int PositionIndex;//| Signal close Buy / close Sell / Open new BUY or SELL order when possible
int TotalNumberOfOrders;
TotalNumberOfOrders = OrdersTotal();// store number of Orders in the variable
for(PositionIndex = TotalNumberOfOrders - 1; PositionIndex >= 0 ; PositionIndex --)// for loop to loop through all Orders . . COUNT DOWN TO ZERO !
{
if(!OrderSelect(PositionIndex, SELECT_BY_POS, MODE_TRADES)) continue;// if the OrderSelect fails advance the loop to the next PositionIndex
if(OrderMagicNumber() == MagicNumber // does the Order's Magic Number match our EA's magic number ?
&& OrderSymbol() == Symbol() // does the Order's Symbol match the Symbol our EA is working on ?
&& (OrderType() == OP_BUY // is the Order a Buy Order ?
|| OrderType() == OP_SELL )) // or is it a Sell Order ?
if (! OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage*PipMultiplier,DarkOrange )) //try to close the order
Print("Order Close failed, order number: ", OrderTicket(), " Error: ", GetLastError()); //if the Order Close failed print some helpful information
if(trendNow>0 && (NLD1>NLD2) && RSIfilter>52) // Check if new entry condition is given
{
OpenBuy_=true;
}
else
if(trendPrev>0 && (NLD1<NLD2) && RSIfilter<42)
{
OpenSell_=true;
}
} // end of For loop
Mntiwana
Here is the EA for B& S with 15 warnings left. If some one could tell me how to clear Declaration of global such as “declaration of 'trailingprofit' hides global declaration at line 62 mnt-BuyersSellers EA v1.00.mq4 915 53” I will clear it up.
I also need a few files to run it.
2016.12.17 16:01:35.347 2016.11.01 00:47 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\4BARS-MTF-BBH 1.06.ex4' [2]
2016.12.17 16:01:29.815 2016.11.01 00:17 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\BullBearHelper 1.00.ex4' [2]
2016.12.17 16:01:29.815 2016.11.01 00:17 cannot open file 'C:\FXPrograms\Tallinex\MQL4\indicators\AdaptiveLaguerreFilter.ex4' [2]
And ,"Slope Direction Line"
Let me Know
Ray
贸易商杜克
谢谢你的兴趣,附件中的indi包,实际上整个系统是来自FF(http://www.tradingsystemforex.com/ideas-for-expert-advisors/4662-buyers-sellers-ea.html)。
gspe正在研究它,但我认为整个EA框架来自 "funyoo",我只对EA代码感兴趣,作为创建一些新的EA的样本/模型框架,他们的战略的其余部分并不完整,根据我的猜测,我们可以形成比这更好的,我们现在有100倍的指标:)
问候
"crsnapebtinternetcom"和MLADEN .....,然后我测试,它工作,但需要一些认证:)
问候
贸易商杜克
谢谢你的兴趣,附件中的indi包,实际上整个系统是来自FF(http://www.tradingsystemforex.com/ideas-for-expert-advisors/4662-buyers-sellers-ea.html)。
gspe正在研究它,但我认为整个EA框架来自 "funyoo",我只对EA代码感兴趣,作为创建一些新的EA的样本/模型框架,他们的战略的其余部分并不完整,根据我的猜测,我们可以形成比这更好的,我们现在有100倍的指标:)
问候
各位
Funyoos EAs通常在使用马丁格尔法进行回测时显示出良好的结果。在使用它们时,我会非常小心。