Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (EternallyCurious, howardR), 646 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 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: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
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: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784

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