LMT short + MaxShort + LifeTime; is this working as expected

Posted By: luisd

LMT short + MaxShort + LifeTime; is this working as expected - 02/19/18 17:57

A simple script that is supposed to sell short limit 20 pips above the low of the day and hold for 1 bar and aplly MaxShorts =1;

Is this working as expected?

Code:
function run()
{
	set(PLOTNOW);

	
	BarPeriod 		= 60;
	LookBack			= 120;

	MaxShort			= 1;

	StartDate		= 20121201;
	EndDate			= 20130301;
		
	PlotDate			= 20130101;
	PlotBars			= 240;
	PlotWidth		= 800;
	PlotHeight1		= 600;
	PlotScale		= 8;
	ColorDD			= 0;
	ColorEquity		= 0;
	
	int barsLookback;
	int numDaysBack = 0;
	
	// LOW OF DAY (LMT ENTRY SHORT PRICE)
	barsLookback = timeOffset(CET,0+numDaysBack,22,1);
	if(barsLookback <= 0)
		if(ldow(CET,0+numDaysBack) != 1)
			barsLookback = timeOffset(CET,1+numDaysBack,22,1);
		else
			barsLookback = timeOffset(CET,2+numDaysBack,22,1);
	
	vars highs  = series(priceHigh());
	vars lows 	= series(priceLow());
	var LOD		= MinVal(lows,  barsLookback);

	

	EntryTime 				= 1;		
	LifeTime = 1;

	var entryPriceS 	= LOD + 20 * PIP;
	plot("entryShort",entryPriceS, MAIN, BLUE);
	enterShort(1, -entryPriceS, entryPriceS + 200 *PIP);
	 
	
}



Attached picture LMTshort.png
Posted By: Hredot

Re: LMT short + MaxShort + LifeTime; is this working as expected - 02/19/18 18:15

Why exactly do you expect the green line to exit in these spots?
Can't see it from your code.
Posted By: Zheka

Re: LMT short + MaxShort + LifeTime; is this working as expected - 02/19/18 20:23

MaxShorts/Longs=1 creates "Skipped Trades" (when entry condition is satisfied again) and restarts Lifetime calculation from the most recent such "skipped trade".
Posted By: luisd

Re: LMT short + MaxShort + LifeTime; is this working as expected - 02/19/18 21:17

Hi Zekha, I agree: the count starts over when the entry condition is met, which means price above the blue line (we sell short limit at the blue line).

Still, the behavior does not look correct to me.

Am I alone seeing that?

I rewrote the code bypassing MaxShorts=1 and it works fine
Posted By: luisd

Re: LMT short + MaxShort + LifeTime; is this working as expected - 02/19/18 21:21

I mean, when price bar is entirely below the blue line the LifeTime=1 should trigger and position should close.

I now noticed that my green arrows are wrong. I put them in the wrong place.

But the argument should be correct: positions should close after 1 bar entirely below the blue line.(LifeTime =1)
Posted By: Zheka

Re: LMT short + MaxShort + LifeTime; is this working as expected - 02/21/18 11:47


Yes, in theory they should.

Try these to understand:
0) look at the log - is entry "skipped" on each and every bar?
1) enter on a previous bar's EntryPriceS value
2) experiment with MaxShort=2..5;
© 2024 lite-C Forums