Gamestudio Links
Zorro Links
Newest Posts
nba2king Latest Roster Update Breakdown
by joenxxx. 10/14/25 06:06
Help!
by VoroneTZ. 10/14/25 05:04
Zorro 2.70
by jcl. 10/13/25 09:01
ZorroGPT
by TipmyPip. 10/12/25 13:58
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 10/11/25 18:45
Reality Check results on my strategy
by dBc. 10/11/25 06:15
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (Quad, AndrewAMD), 9,200 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
joenxxx, Jota, krishna, DrissB, James168
19170 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Self-defined MACD #463452
12/04/16 22:26
12/04/16 22:26
Joined: Nov 2016
Posts: 5
M
mey Offline OP
Newbie
mey  Offline OP
Newbie
M

Joined: Nov 2016
Posts: 5
Dear community,

I am trying to define my own MACD, because I get huge signal deviations from Zorro’s pre-defined rMACD compared with that from ProRealTime.

Sounds easy to solve, but I got even stuck with declaration and definition of the pointer variables as a newbee in C.

Could anybody help me here please?

Here is the code from ProRealTime which I want to implement in lite-C:

myMAFastLength = ExponentialAverage[FastLength](close)
myMASlowLength = ExponentialAverage[SlowLength](close)
myMACD = myMAFastLength - myMASlowLength //MACD line
myMACDTrigger = ExponentialAverage[MACDTriggerLength](myMACD) //MACD signal line)
MACDHist = myMACD - myMACDTrigger

This is the definition for the implemented Zorro MACD:

Instead calculation of MACD use the implemented function
MACD(vars Data, int FastPeriod, int SlowPeriod, int SignalPeriod)
rMACD = EMA(Data,FastPeriod)-EMA(Data,SlowPeriod);
rMACDSignal = EMA(rMACD,SignalPeriod);
rMACDHist = rMACD - rMACDSignal;
Results in rMACD, rMACDSignal, rMACDHist. Returns: rMACD.
Parameters: FastPeriod (time period for the fast MA), SlowPeriod (time period for the slow MA), SignalPeriod (time period for smoothing the signal line).

Implementation:
MACD(Price,FastPeriod,SlowPeriod,SignalPeriod);

vars MACDLine = series(rMACD);
vars SignalLine = series(rMACDSignal);
vars Hist = series(rMACDHist);


Here's my trial for implementation:

int
FastPeriod = 12,
SlowPeriod = 26,
SignalPeriod = 9;

vars Price = series(price());
vars myMASlowLength = series(EMA(Price,SlowPeriod));
vars myMAFastLength = series(EMA(Price,FastPeriod));
vars MyMACD = series(EMA(Price,FastPeriod) - EMA(Price,SlowPeriod)); //myMAFastLength - myMASlowLength;
//why does the following not work for MyMACD:?
// vars MyMACD = myMAFastLength – myMASlowLength;

vars MySignalline = series(EMA(MyMACD,SignalPeriod));
vars MyHist = series();

// Calculate the slow EMA.
myMASlowLength = series(EMA(Price,SlowPeriod));

// Calculate the fast EMA.
myMAFastLength = series(EMA(Price,FastPeriod));

// Calculate (fast EMA) - (slow EMA) --> MyMACD
MyMACD = myMAFastLength - myMASlowLength;

Here I get first error message: Syntax error: Wrong type SUB:POINTER:POINTER:POINTER
< MyMACD = myMAFastLength - myMASlowLength; >

// Calculate the signal/trigger line.
MySignalline = EMA(MyMACD,SignalPeriod);

// Calculate the histogram.
MyHist = MyMACD - MySignalline;


Thanks so much for any help in advance.

Re: Self-defined MACD [Re: mey] #463462
12/05/16 10:46
12/05/16 10:46
Joined: Jul 2000
Posts: 28,028
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,028
Frankfurt
It's not myMAFastLength - myMASlowLength, but myMAFastLength[0] - myMASlowLength[0] for the last value of the series.

Re: Self-defined MACD [Re: jcl] #463464
12/05/16 18:55
12/05/16 18:55
Joined: Nov 2016
Posts: 5
M
mey Offline OP
Newbie
mey  Offline OP
Newbie
M

Joined: Nov 2016
Posts: 5
Hi jcl,
thanks for quick reply.
I changed it to
MyMACD = myMAFastLength[0] - myMASlowLength[0];
but I still receive the same error message and assume,
that my vars declarations are the problem.

I tried also this (which works without error message):
vars MyMACD = series(myMAFastLength[0] - myMASlowLength[0]);
..but then I receive same error again for the MyMACD definition.

What is wrong here?
Thanks so much.


Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1