
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
This part
if(newbar==Time[0])return(0);
else newbar=Time[0];
int ticket, total;
if(Bars<100)
{
Print("bars less than 100");
return(0);
}
if(TakeProfit<10)
{
Print("TakeProfit less than 10");
return(0); // check TakeProfit
}
Is preventing the ea to close orders at certain time if it is not a first tick of a new bar and if the profit is not > 10 pipsHi mladen, I have removed that part of the coding and still my ea does not close at my desired timing.
Do you have any idea what could be the reason? Thanks.
Regards
Ryan
Hi mladen, I have removed that part of the coding and still my ea does not close at my desired timing.
Do you have any idea what could be the reason? Thanks.
Regards
RyanThe way it is written, it will close orders only, and only if the broker time is exactly 07:00:00
The way it is written, it will close orders only, and only if the broker time is exactly 07:00:00
Hi mladen, is there any other way around this as it does not seem to be working here.
Regards
Ryan
Hi mladen, is there any other way around this as it does not seem to be working here.
Regards
RyanTry using
If (TimeCurrent()>= StringToTime("07:00:00"))
instead
Try using
If (TimeCurrent()>= StringToTime("07:00:00"))
insteadHi mladen, it is still not working. I am wondering if it could be due to this lines here... either the OrdersTotal or OrderSelect might be causing the problem?
for (int i=OrdersTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
Regards
Ryan
Hi mladen, it is still not working. I am wondering if it could be due to this lines here... either the OrdersTotal or OrderSelect might be causing the problem?
for (int i=OrdersTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
Regards
RyanNo. Those lines are correct
No. Those lines are correct
Hi mladen, because i set my ea to have only 1 trade at any point in time and i noticed that OrdersTotal set my int i count to negative 0 by 1-1, i>=0; i-- will make my i=-1
so was wondering if this could be the error.
else if(total > 1) //to close off orders based on timing... not yet resolved.
{
if (Hour()==7 && Minute()==30)
{
for (int i=OrdersTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (!UseCurrSymbol || OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
pBid=MarketInfo(OrderSymbol(),MODE_BID);
OrderClose(OrderTicket(),OrderLots(),pBid,1,Blue);
}
if (OrderType()==OP_SELL)
{
pAsk=MarketInfo(OrderSymbol(),MODE_ASK);
OrderClose(OrderTicket(),OrderLots(),pAsk,1,Red);
}
}
}
}//
}
return(0);
}
Hi mladen, because i set my ea to have only 1 trade at any point in time and i noticed that OrdersTotal set my int i count to negative 0 by 1-1, i>=0; i-- will make my i=-1
so was wondering if this could be the error.
else if(total > 1) //to close off orders based on timing... not yet resolved.
{
if (Hour()==7 && Minute()==30)
{
for (int i=OrdersTotal()-1; i>=0; i--)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
{
if (!UseCurrSymbol || OrderSymbol()==Symbol())
{
if (OrderType()==OP_BUY)
{
pBid=MarketInfo(OrderSymbol(),MODE_BID);
OrderClose(OrderTicket(),OrderLots(),pBid,1,Blue);
}
if (OrderType()==OP_SELL)
{
pAsk=MarketInfo(OrderSymbol(),MODE_ASK);
OrderClose(OrderTicket(),OrderLots(),pAsk,1,Red);
}
}
}
}//
}
return(0);
}Please replace this : f (Hour()==7 && Minute()==30) with the line I sent you and try then
OrdersTotal() will return 1 if there is an opened order. When using OrderSelect(), that 0 (OrdersTotal()-1) will select the correct order. If OrdersTotal() returns 0, then there are no opened orders in the active orders pool
Please replace this : f (Hour()==7 && Minute()==30) with the line I sent you and try then OrdersTotal() will return 1 if there is an opened order. When using OrderSelect(), that 0 (OrdersTotal()-1) will select the correct order. If OrdersTotal() returns 0, then there are no opened orders in the active orders pool
Hi mladen, sad to say I just retried it again and its still not working.
Is there another way which I can close my trade based on specific timing?
Regards
Ryan
Please replace this : f (Hour()==7 && Minute()==30) with the line I sent you and try then OrdersTotal() will return 1 if there is an opened order. When using OrderSelect(), that 0 (OrdersTotal()-1) will select the correct order. If OrdersTotal() returns 0, then there are no opened orders in the active orders pool
Hi mladen, I have managed to resolve the issue. it seems like this liner was causing the problem.. the code is working after i removed it.
else if(total > 1)
thanks for your assistance...
Regards
Ryan