Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
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
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Equity Curve Trading Question #477646
07/19/19 09:51
07/19/19 09:51
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
Hi guys,
im new here and i want to thanks jcl for this beautiful software, it's amazing and it deserve more popularity.

my first question are about phantom trade and equity curve trading.

if i got an algo that stay in market 50% of time i got a simple problem; this is my code:
Code
function run()
{
	set(LOGFILE|PLOTNOW|PARAMETERS);
	NumYears = 3;
	Verbose = 2;
	LookBack = 1000;
	vars Price = series(priceClose());
	vars Trends1 = series(SMA(Price,30));
	vars Trends2 = series(SMA(Price,90));
	
// generate equity curve including phantom trades
  vars EquityCurve = series(EquityLong+EquityShort);
  //vars EquityCurve2 = series(Equity);
  vars EquityLP = series(LowPass(EquityCurve,100));
  
 
  if(EquityCurve[0] < EquityLP[0])
    setf(TradeMode,TR_PHANTOM); // drawdown -> phantom trades
  else
    resf(TradeMode,TR_PHANTOM); // profitable -> normal trades
  //setf(TrainMode, PHANTOM);
 
		if(crossOver(Trends1,Trends2))
			enterShort();
		else if(crossUnder(Trends1,Trends2))
			exitShort();

	plot("eq",EquityCurve,NEW,BLUE);
   plot("eqlp",EquityLP,0,RED);
	//plot("eq2",EquityCurve2,NEW,BLUE);
}


if i plot the equity curve and its lowpass i see that when the strategy is out of market the equitycurve gone flat and so the lowpass on the equity too. I think that this can bring miscalculation about entries and phantom trade. How can i get an equity curve that dont go flat when the algo is out of market?
thanks and have a good day wink

Re: Equity Curve Trading Question [Re: maxwellreturn] #477648
07/19/19 11:57
07/19/19 11:57
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Hi, you can use static series for the equity curve and shift them by script when the system is in the market and otherwise not. For a static series use a negative length like this

vars EquityCurve = series(EquityLong+EquityShort,-LookBack);

and for shifting when in the market

if(NumOpenLong+NumOpenShort > 0) shift(EquityCurve,EquityLong+EquityShort,LookBack);

Hope this helps!

Re: Equity Curve Trading Question [Re: Petra] #477650
07/19/19 14:24
07/19/19 14:24
Joined: Jul 2019
Posts: 26
M
maxwellreturn Offline OP
Newbie
maxwellreturn  Offline OP
Newbie
M

Joined: Jul 2019
Posts: 26
hi petra and thanks for your time and answer laugh

i ve tried what you suggest but i got an error of inconsistent series. i've added the new part here:

Code
// generate equity curve including phantom trades
  
  vars EquityCurve = series(EquityLong+EquityShort, -LookBack);
 if(NumOpenLong+NumOpenShort > 0) shift(EquityCurve,EquityLong+EquityShort,LookBack);
  vars EquityLP = series(LowPass(EquityCurve,200),-LookBack);
  if(NumOpenLong+NumOpenShort > 0) shift(EquityLP,LowPass(EquityCurve,200),LookBack);

  if(EquityCurve[0] < EquityLP[0])
    setf(TradeMode,TR_PHANTOM); // drawdown -> phantom trades
  else
    resf(TradeMode,TR_PHANTOM); // profitable -> normal trades

seems quite hard obtain this thing frown

this is the error message that i get in the log. Seems that when algo opens the first trade it goes on error
Quote

[1034: Mon 17-03-06 07:00] 0000 +0.19 1/0 (1.05996)
Error 041: Inconsistent series!
Bar 1033: 6 - bar 1034: 7


thanks to all of you that want to help. Have a nice day and sorry for my english

Last edited by maxwellreturn; 07/19/19 14:31.

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1