Thread: Ask!
View Single Post
  #933 (permalink)  
Old 01-17-2008, 11:17 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by RaidenDSI View Post
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.
It's easy: the code above is a function, so you need to call it somewhere. If you never call it, this function will never run, so it's useless to keep it in the compiled file; that's the meaning of the error you get.
Reply With Quote