Can anyone help me with this code:
void CloseOrder(int minutes)
{
int total = OrdersTotal();
for (int cnt = 0 ; cnt < total ; cnt++)
{
OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
if ((CurTime()-OrderOpenTime())>minutes*60)
{
if(OrderType()==OP_BUY)
OrderClose(OrderTicket(),OrderLots(),Bid,Slippage, Violet);
if(OrderType()==OP_SELL)
OrderClose(OrderTicket(),OrderLots(),Ask,Slippage, Violet);
}
}
}
This is code that I am trying to incorporate into an EA but am having problems when compiling. I get this error: Function "CloseOrder" is not referenced and will be removed from exp-file
This code was posted by codersguru from this post:
How to close trades after a certain amount of time has passed
What I am trying to do is to develop a system that will close all trades after x amount of time since opening of the most recent trade.
I have very little knowledge in coding but am trying to learn.
If this type of problem has been addressed before then could someone please point me to the proper thread as I have not been able to find one on this forum using the search function. Thank you.