You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
try this...
//-------------------------------
for(cnt=0;cnt<HistoryTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
if(OrderSymbol()==Symbol()&& OrderMagicNumber()==MagicNo)
{
int lastclosetime = OrderCloseTime();
if(lastclosetime>iTime(Symbol(),wrkPeriod,0))
{
tradeenable=false;
}
else
{
tradeenable=true;
}
}
}
//-------------------------------
may help ^_^
try this...
//-------------------------------
for(cnt=0;cnt<HistoryTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_HISTORY);
if(OrderSymbol()==Symbol()&& OrderMagicNumber()==MagicNo)
{
int lastclosetime = OrderCloseTime();
if(lastclosetime>iTime(Symbol(),wrkPeriod,0))
{
tradeenable=false;
}
else
{
tradeenable=true;
}
}
}
//-------------------------------
may help ^_^Can you add the code directly to the EA, Please?... I almost don't know anything about writing the code. I create this EA with EA builder from a web. Only a few that i know about MQL, that's why i'm asking you bro...if don't mind, please...
after the code above ,
//------------------------------
if(CalculateCurrentOrders(Symbol())==0)<<--check the opening order
{
if(tradeenable)<<--allow to trade
{
if(your Buy condition)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,spread,Ask-SLlevel*Point,Ask+TakeProfit*Point,your Order Comment,MagicNo,0,OpenBuy_Sig_Color);
}
if(your sell condition)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,spread,Bid+SLlevel*Point,Bid-TakeProfit*Point,your Order Comment,MagicNo,0,OpenBuy_Sig_Color);
}
}
else ticket=-1;
if(ticket>0)
{
if(OrderSelect(ticket,SELECT_BY_TICKET,MODE_TRADES))
{
Print("Order opened : ",OrderOpenPrice());
return(0);
}//end OrderSelect
return(0);
}//end ticket>0
return(0);
}//end of CalculateCurrentOrders()
//------------------------------
total = OrdersTotal();
for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()<=OP_SELL && OrderSymbol()==Symbol())
{
if(OrderType()==OP_BUY) // long position is opening
{
if(your close buy condition)
{
OrderClose(OrderTicket(),OrderLots(),Bid,spread,CloseBuy_Sig_Color);
// close position
return(0); // exit
}//end close buy
// check for trailing stop
if(TrailingStop>0){
if(Bid-OrderOpenPrice()>Point*TrailingStop)
{
if(OrderStopLoss()<Bid-Point*TrailingStop)
{
OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Modified_Sig_Color);
return(0);
}//end OrderStopLoss()<Bid-Point*TrailingStop
}//end Bid-OrderOpenPrice()>Point*TrailingStop
}//end TrailingStop>0}//end OrderType()==OP_BUY
else // go to short position
{
if(your close sell condition)
{
// should it be closed?
OrderClose(OrderTicket(),OrderLots(),Ask,spread,CloseSell_Sig_Color);
// close position
return(0);// exit
}//end closesell
// check for trailing stop
if(TrailingStop>0){
if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
{
if((OrderStopLoss()>(Ask+Point*TrailingStop)) || (OrderStopLoss()==0))
{
OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Modified_Sig_Color);
return(0);
}//end OrderStopLoss()
}//end OrderOpenPrice()-Ask >(Point*TrailingStop)
}//end TrailingStop>0}//end else
}//end OrderType()<=OP_SELL && OrderSymbol()==Symbol()
}//end for
//-------------------------------------
hope this help ^_^
Here Is An Example , But You Need To Add Your Trade Condition Yourself ^_^
Here Is An Example , But You Need To Add Your Trade Condition Yourself ^_^
Thank's very much,..it's work. now i'm ready going to test run my strategy