Trade parameters 2 - time limits

LifeTime

Trade time limit in bars. After the given number of bars (default: 0 for no time limit), the trade closes at the open of the next bar. 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. The life time of open trades is extended by enter commands that do not open a trade due to MaxLong/MaxShort or due to a margin or risk limit. Open trades of the same component get then automatically the life time that the new trade would have. 

EntryTime

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, the trade is removed and a "Missed Entry" message is printed to the log file.

Range:

Number of bars.

Type:

int
 

OrderDelay

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.

OrderDuration

GTC order duration in seconds. The order is automatically cancelled after the given time even when the trade is not completely filled. The broker API must support the SET_ORDERTYPE and DO_CANCEL commands. This variable affects all open GTC trades.

Range:

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

Type:

var

Remarks:

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