Trade parameters 2 - time limits


Trade time limit in bars. Close the trade automatically when it was open for the given number of bars (default: 0 for no time limit). Trades are only closed when the market is open. If the entry happens intrabar due to an Entry or OrderDelay setting, LifeTime = 1 causes a trade duration of 1 bar plus the remainder of the opening bar. When a new trade cannot be entered due to the MaxLong/MaxShort limit, open trades of the same component are automatically updated to the life time that the new trade would have.


Pending order lifetime in bars. 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 delay), or when the entry limit is met, whatever happens first. The delay can be given in high resolution (0.000001 = 1 microsecond). Useful for splitting a large order into smaller portions ("iceberg trades"), for an adaptive entry/exit algorithm or for simulating latency in HFT fill mode.


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
	OrderDelay = Delay;
	Entry = -0.2*PIP * sqrt(Delay); // entry limit for additional profit

See also:

bar, enterLong/Short, Stop, Entry, TickTime


► latest version online