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
1 registered members (degenerate_762), 1,098 guests, and 2 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
MAs data and graph are wonky #486406
08/15/22 06:40
08/15/22 06:40
Joined: Aug 2022
Posts: 5
K
kwyx Offline OP
Newbie
kwyx  Offline OP
Newbie
K

Joined: Aug 2022
Posts: 5
Why my middle MAs are wonky. Golden is SMA, Blue is EMA.
Three bands being High, Close, Low respectively.
My code:

Code
	StartDate = 20180101;
	EndDate = 20201231;
	LookBack = 300;
	
	BarPeriod = 60;
        int SMA_PERIOD = 72;
        int EMA_PERIOD = 12;
        int ADX_PERIOD = 14;
        sma_high  = series(SMA(seriesH(),SMA_PERIOD)); 
	sma_mid   = series(SMA(series(price()),SMA_PERIOD));
	sma_low   = series(SMA(seriesL(),SMA_PERIOD));
	ema_high  = series(EMA(seriesH(),EMA_PERIOD));
	ema_mid  = series(EMA(series(price()),EMA_PERIOD));
	ema_low  = series(EMA(seriesL(),EMA_PERIOD));
	adx = series(ADX(ADX_PERIOD));

	 plot("ema_high",ema_high,LINE ,BLUE);
	 plot("ema_mid",ema_mid,LINE ,BLUE+TRANSP);
	 plot("ema_low",ema_low,LINE ,BLUE);
	 plot("sma_high",sma_high,LINE ,ORANGE);
	 plot("sma_mid",sma_mid,LINE ,ORANGE+TRANSP);
	 plot("sma_low",sma_low,LINE ,ORANGE);

Attached Files wonky MA.jpg
Last edited by kwyx; 08/15/22 06:41.
Re: MAs data and graph are wonky [Re: kwyx] #486408
08/15/22 14:27
08/15/22 14:27
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
series(price) is not Close. seriesC() is Close.

Aside from that, series() is filled with the inital value at start, while seriesC() is not.

Re: MAs data and graph are wonky [Re: jcl] #486409
08/15/22 16:30
08/15/22 16:30
Joined: Aug 2022
Posts: 5
K
kwyx Offline OP
Newbie
kwyx  Offline OP
Newbie
K

Joined: Aug 2022
Posts: 5
Actually I wanted the typical price for the mid line (H+L+C)/3. Can I do something like:
sma_low = series(SMA((seriesL()+seriesC()+seriesH())/3,SMA_PERIOD));

Also- would seriesC[0] give the current price for the current (incomplete bar).

One more query- I migrated my algo from MQL5 to Zorro which is kinda C++ to C migration.
The business logic lines are hardly changed. I'm raking my brains but I can't figure out why the algo is severely bad(negative profit) results in Zorro- any pointers how do I debug?

Does Zorro change TP/SL despite me setting up exclusively when I do enterLong()/enterShort?

Re: MAs data and graph are wonky [Re: kwyx] #486412
08/16/22 07:13
08/16/22 07:13
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
That would be SMA(series((priceH()+priceL()+priceC())/3),Period). And there is no incomplete bar in the run function.

Even with the same strategy, you will likely get a different and usually worse backtest result from Zorro than from MT5. At least I hope so. For the details, read the chapter about code migration in the manual.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1