/*[[ Name := fnExitBar Author := Copyright © 2005, iExpertAdvisor, LLC Link := http://www.iExpertAdvisor.com ]]*/ inputs: numBars(4); vars: cnt(0), Slippage(0); for cnt=1 to TotalTrades begin if( Symbol == Ord(cnt,VAL_SYMBOL) ) then { if( CurTime() > (LastTradeTime()+ (Period()*numBars*Period))) then { //close the order If (Ord(cnt, VAL_TYPE ) == OP_BUY ) then { CloseOrder( Ord(cnt,VAL_TICKET), Ord(cnt,VAL_LOTS), Bid, Slippage, RED ); print("Buy Close Time:", TimeToStr(CurTime)); } else { CloseOrder( Ord(cnt,VAL_TICKET), Ord(cnt,VAL_LOTS), Ask, Slippage, RED ); print("Sell Close Time:", TimeToStr(CurTime)); } } return(0); // do not open more then 1 order }; // end if symbol end; return(0);