Trade parameters 2 - time limits


Trade time limit. Close the trade automatically after the given number of bars (default: 0 for no time limit). Trades are only closed when the market is open. If the entry is delayed due to an Entry or EntryDelay setting, LifeTime = 1 causes a trade duration of 1 bar plus the remainder of the opening bar.


Pending order lifetime. When an enter command is given, wait the given number of bars (default: 1) until the entry limit is met. If that does not happen during that time, cancel the trade. A "Missed Entry" message is then printed to the log file.


Number of bars.




Order entry delay in seconds. Open the trade either after the given delay time (default: 0 - no entry delay), or when the entry limit is met, whatever happens first. With the fractional part of this variable the entry time can be determined with a precision of about 10 ms.


Second units, f.i. 1.23 == 1230 ms.




Examples (see also Grid.c and Hacks&Tricks):

// Use an entry limit and an entry delay for not entering trades at the same time
// Call this function before entering a trade
void setDelay(var Seconds)
	static int PrevBar = 0;
	static var Delay = 0;
	if(Bar != PrevBar) { // reset delay at any new bar
		Delay = 0;
		PrevBar = Bar;
	Delay += Seconds; // increase delay within the bar
	EntryDelay = Delay;
	Entry = -0.2*PIP * sqrt(Delay); // entry limit for additional profit

See also:

bar, enterLong/Short, Stop, Entry, TickTime


► latest version online