I'd like to know to get
Close sell + Buy and
Close buy+ Sell at the same bar
have I set oppositeclose input :true ?
Thank you very much for your help
Best Regards
Massimo
I'd like to know to get
Close sell + Buy and
Close buy+ Sell at the same bar
have I set oppositeclose input :true ?
Thank you very much for your help
Best Regards
Massimo
Hi maxmiral,
In the extern parameters, add :
After the entry conditions in the start body, add :Code:extern bool oppositeclose=true;
After the start(){} body, add :Code:if((oppositeclose && sell))closebuy(); if((oppositeclose && buy))closesell();
Finally replace sell and buy by your respective parameters (that determine the nature of the signal).Code://|---------close void closebuy(){ RefreshRates(); if(OrdersTotal()>0){ for(int i=OrdersTotal();i>=0;i--){ OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUY){ OrderClose(OrderTicket(),OrderLots(),Bid,slippage*mt); } } } } void closesell(){ RefreshRates(); if(OrdersTotal()>0){ for(int i=OrdersTotal();i>=0;i--){ OrderSelect(i,SELECT_BY_POS,MODE_TRADES); if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELL){ OrderClose(OrderTicket(),OrderLots(),Ask,slippage*mt); } } } }
Or you can simply add closebuy() before the sell ordersend function and closesell() before the buy ordersend function.
Trading forex risk disclaimer. Exclusive EAs in the Elite section.
Hi Funyoo,
I modified extern bool oppositeclose=true and
I added in Simple ZigZag v.1.01 piece of code
" //|---------close
void closebuy(){
RefreshRates();
if(OrdersTotal()>0){
for(int i=OrdersTotal();i>=0;i--){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_BUY){
OrderClose(OrderTicket(),OrderLots(),Bid,slippage* mt);
}
}
}
}
void closesell(){
RefreshRates();
if(OrdersTotal()>0){
for(int i=OrdersTotal();i>=0;i--){
OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
if(OrderSymbol()==Symbol() && OrderMagicNumber()==magic && OrderType()==OP_SELL){
OrderClose(OrderTicket(),OrderLots(),Ask,slippage* mt);
}
}
}
} "
Could you build another version of this EA this by adding another filter true or false
I think "Laguerre filter" could be helpfull in this case (without take profit/stop loss (hide= true) )
Close Sell + Buy only after ZigZag Pointer GreeArrow position on chart stable for 3-4-5 bars (as input selectable) and if price is only above Laguerre filter and then on other side and on reverse
Close Buy + Sell only after ZigZag Pointer Red Arrow position on chart stable for 3-4-5 bars (as input selectable) and if price is only down Laguerre filter .
Thank you very much and Happy New Year.
Massimo
Hi maxmiral,
Please post your request in the Elite section.
Trading forex risk disclaimer. Exclusive EAs in the Elite section.