Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (monk12, Quad), 830 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
LMT short + MaxShort + LifeTime; is this working as expected #471097
02/19/18 17:57
02/19/18 17:57
Joined: Jan 2018
Posts: 29
L
luisd Offline OP
Newbie
luisd  Offline OP
Newbie
L

Joined: Jan 2018
Posts: 29
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 Files LMTshort.png
Re: LMT short + MaxShort + LifeTime; is this working as expected [Re: luisd] #471098
02/19/18 18:15
02/19/18 18:15
Joined: Sep 2017
Posts: 235
H
Hredot Offline
Member
Hredot  Offline
Member
H

Joined: Sep 2017
Posts: 235
Why exactly do you expect the green line to exit in these spots?
Can't see it from your code.

Re: LMT short + MaxShort + LifeTime; is this working as expected [Re: Hredot] #471102
02/19/18 20:23
02/19/18 20:23
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783
MaxShorts/Longs=1 creates "Skipped Trades" (when entry condition is satisfied again) and restarts Lifetime calculation from the most recent such "skipped trade".

Last edited by Zheka; 02/19/18 20:25.
Re: LMT short + MaxShort + LifeTime; is this working as expected [Re: Zheka] #471105
02/19/18 21:17
02/19/18 21:17
Joined: Jan 2018
Posts: 29
L
luisd Offline OP
Newbie
luisd  Offline OP
Newbie
L

Joined: Jan 2018
Posts: 29
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

Re: LMT short + MaxShort + LifeTime; is this working as expected [Re: luisd] #471106
02/19/18 21:21
02/19/18 21:21
Joined: Jan 2018
Posts: 29
L
luisd Offline OP
Newbie
luisd  Offline OP
Newbie
L

Joined: Jan 2018
Posts: 29
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)

Re: LMT short + MaxShort + LifeTime; is this working as expected [Re: luisd] #471170
02/21/18 11:47
02/21/18 11:47
Joined: Jul 2017
Posts: 783
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 783

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;


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1