Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Quad), 748 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
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