Help Required Please

 

Can Someone please assist me: How can I automatically close an existing Order when two Bars have formed after the Order was sent Originally two days ago. I'm using the Daily Charts. Thank you

 
Add
datetime T;
as a global variable

Add
T=Time[0];
right below an opening order code

finally use
if (T==Time[2])
 {
    OrderClose(...);
 }
to close the existing order at the opening of the 3rd(current) day.
 
don't you have to increment T somehow?
 

What he suggests is:

..
..
  OrderSend(...);
  GlobalVariableSet("TimeOfTradeBar", Time[0]);
..
..
  if( GlobalVariableGet("TimeOfTradeBar") == Time[2]){
     OrderClose(...);
  }
 
faqcya:
don't you have to increment T somehow?
Time[n] is the opening time of "n" candle (Current bar is 0), we don't need to increment it.

phy:

What he suggests is:

..
..
  OrderSend(...);
  GlobalVariableSet("TimeOfTradeBar", Time[0]);
..
..
  if( GlobalVariableGet("TimeOfTradeBar"); == Time[2]){
     OrderClose(...)
  }
Thanks Phy,
from my experience we can put
datetime T;
under input parameter(s) to use it as a global variable.
CMIIW
Reason: