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
5 registered members (Quad, TipmyPip, degenerate_762, AndrewAMD, Nymphodora), 997 guests, and 5 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
Page 1 of 2 1 2
Position stopped even without stop loss / exit rule #477508
07/03/19 12:46
07/03/19 12:46
Joined: Apr 2019
Posts: 48
Albay
M
marr Offline OP
Newbie
marr  Offline OP
Newbie
M

Joined: Apr 2019
Posts: 48
Albay
Im testing a simple strategy enter long when the price is above the MAs , I wanted to see if the variable are behaving properly including the entry / exit and stop loss but I encounter this behavior where the position have its own exit, even without specifying any rules, on zorro manual Stop is default to 0. Can someone explain why is it happening

Heres the code:

Code
function run()	{
	set(TICKS|LOGFILE);
	
	// Minute
	BarPeriod = 1;
	Capital = 10000;
	LookBack = 500;
	NumWFOCycles = 10;
	Margin = 0.50 * Capital;

	while(asset(loop(Assets))){

		vars Close = series(priceClose());
		vars Low = series(priceLow());

		int EMA13TimePeriod = 13;
		int EMA8TimePeriod  = 8;
		int EMA5TimePeriod  = 5;
		int ADXTimePeriod   = 14;
		

		vars EMA13 =  series(EMA(Close, EMA13TimePeriod));
		vars EMA8  = series(EMA(Close, EMA8TimePeriod));
		vars EMA5  = series(EMA(Close, EMA5TimePeriod));
		
		vars ADX   = series(ADX(ADXTimePeriod));
	
		MaxLong = MaxShort = 1;
		
		if (Close > EMA13 && Close > EMA8 && Close > EMA5)
		{

			enterLong();
			
		}

		plot("EMA13",EMA13,LINE,ORANGE);
		plot("EMA8",EMA8,LINE,ORANGE);
		plot("EMA5",EMA5,LINE,ORANGE);
		plot("ADX",ADX,NEW|LINE,BLUE);

	}

	
}


Attached Files EMA3_TSLA.png
Re: Position stopped even without stop loss / exit rule [Re: marr] #477510
07/03/19 14:34
07/03/19 14:34
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
If you set LOGFILE and Verbose = 7+DIAG, you should find the reason why in your logs.

Re: Position stopped even without stop loss / exit rule [Re: AndrewAMD] #477512
07/03/19 15:55
07/03/19 15:55
Joined: Apr 2019
Posts: 48
Albay
M
marr Offline OP
Newbie
marr  Offline OP
Newbie
M

Joined: Apr 2019
Posts: 48
Albay
this is what i get when i set that

Code
Sell 1@325.32: -2088 Bid 325.12 at 13:09:00
Opn 327.21 Cls 325.32 Spr 0.200000 Slp 342.11 Rol -0.00 Com 0.00 Net 1
Max Loss 0.00 -> 2087.88
Max Bars 0 -> 569-480


clearly Max Loss have something to do with my issue, tho i can't find about this on the manual

Re: Position stopped even without stop loss / exit rule [Re: marr] #477517
07/04/19 06:36
07/04/19 06:36
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
When you get a margin call, your trades are liquidated at market.

Re: Position stopped even without stop loss / exit rule [Re: jcl] #477520
07/04/19 07:03
07/04/19 07:03
Joined: Apr 2019
Posts: 48
Albay
M
marr Offline OP
Newbie
marr  Offline OP
Newbie
M

Joined: Apr 2019
Posts: 48
Albay
I wanted to prevent this but i dont understant why the trades are exiting too early even without specifying exitlong and stop, since they are default at 0, i should expect a 1 huge loss

Re: Position stopped even without stop loss / exit rule [Re: marr] #477521
07/04/19 07:23
07/04/19 07:23
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Your margin size looks wrong, such a trade will not live long.

Re: Position stopped even without stop loss / exit rule [Re: Petra] #477526
07/04/19 12:30
07/04/19 12:30
Joined: Apr 2019
Posts: 48
Albay
M
marr Offline OP
Newbie
marr  Offline OP
Newbie
M

Joined: Apr 2019
Posts: 48
Albay
the margin that I used came from a book, it is originally 5% of my capital, and experimented with different values, tho the time of margin call is different, but i wanted to know why the trade exits too early which causes failure of the system , even specifying hard rules

Re: Position stopped even without stop loss / exit rule [Re: marr] #477528
07/04/19 14:25
07/04/19 14:25
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
A margin call is not good. That your trades are closed is then the least of your worries! grin

Delete your lines with "Margin" and "Capital", they are the reason of the margin call. Your trade signal is also wrong. Begin with the tutorial, there is also a workshop where you learn what "Margin" and "Capital" are and how to use them.

Re: Position stopped even without stop loss / exit rule [Re: Petra] #477529
07/04/19 14:38
07/04/19 14:38
Joined: Apr 2019
Posts: 48
Albay
M
marr Offline OP
Newbie
marr  Offline OP
Newbie
M

Joined: Apr 2019
Posts: 48
Albay
I understand that the strategy is bad, i dont mind margin call actually, its just, there are trades that exit at 0 sec after it enter which is kinda weird for me, since I did not set up a stop loss and risk which is now default to 0 and the code doesnt have exitLong() that would make the trade exit right away. That is the mystery that i am trying to look out for days.

Here is the testrade logs of some part on the image. ive also display the duration of the trade.

Code
"Name","Type","Asset","ID","Lots","Open","Close","Entry","Exit","Profit","Roll","ExitType","Duration"
"cloud","Long","TSLA",4802701,1,2019-03-20 09:07:00,2019-03-20 09:07:00,269.22,269.02,-200,0,"Sold",0
"cloud","Long","TSLA",4803601,1,2019-03-20 09:16:00,2019-03-20 09:16:00,269.22,269.02,-200,0,"Sold",0
"cloud","Long","TSLA",4805101,1,2019-03-20 09:31:00,2019-03-20 09:31:00,269.95,269.75,-200,0,"Sold",0
"cloud","Long","TSLA",4805801,1,2019-03-20 09:38:00,2019-03-20 09:38:00,270,269.64,-365,0,"Sold",0

Re: Position stopped even without stop loss / exit rule [Re: marr] #477532
07/04/19 15:40
07/04/19 15:40
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Online
Serious User
AndrewAMD  Online
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
Originally Posted by marr
i dont mind margin call actually
Your broker will strongly disagree.

Also, this is wrong:
Code
if (Close > EMA13 && Close > EMA8 && Close > EMA5)
Write it like this:
Code
if (Close[0] > EMA13[0] && Close[0] > EMA8[0] && Close[0] > EMA5[0])

Page 1 of 2 1 2

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1