1 (edited by wiart 2016-01-31 14:38:00)

Topic: Creating new indicator MACD Zero Lag

Hello,

I'm enjoying using FSB and I'm trying to create a new indicator based on MACD Zero Lag formula that can be found here:
https://www.mql5.com/en/code/9993
ZeroLAG MACD(i) = (2*EMA(Close, FP, i) - EMA(EMA(Close, FP, i), FP, i)) - (2*EMA(Close, SP, i) - EMA(EMA(Close, SP, i), SP, i));
ZeroLAG MACD Signal(i) = 2*EMA(ZeroLAG MACD(i), SigP, i) - EMA(EMA(ZeroLAG MACD(i), SigP, i), SigP, i);

where:
EMA - exponential moving average;
Close - a price of the closing of the bar;
FP - a period of the quick moving average;
SP - a period of the slow moving average;
SigP - a period of the signal moving average;

So, I started coding, using other custom indicators. Unfortunately, I'm lacking a lot of knowledge on the FSB APIs, and I get an "array out of bound" error message when I try to use it in FSB to create strategies and don't know if there is a way to debug (step by step).
I would also have loved to have the basic MACD indicator code from FSB, but it's not available in the indicators directory.
The goal is to have very simple entry/exit rules (histogram higher or lower than 0, or signal line, etc).


Would somebody kind enough to point me to the API documentation, or do a quick check on the code attached (I'm sure my mistakes are fairly obvious to a coder accustomed to creating indicators for FSB)?

Many thanks,
Laurent

Post's attachments

MACD Zero Lag.cs 10.71 kb, 2 downloads since 2016-01-31 

You don't have the permssions to download the attachments of this post.

Re: Creating new indicator MACD Zero Lag

Hey Laurent,

I'm not on my work machine at the moment, so I could only glance your project. But you have used nonconventional (purely for my taste wink ) approach for some things. There seems to be that the number of components is not declared, that's one possible reason for out of bounds error. If I were you I would take the FSB's source of macd histogram and then adjust the code. You can find the sources here - https://github.com/PopovMP/FSB_Pro_Indicators

Hope this helps a bit!

3 (edited by wiart 2016-01-31 21:45:31)

Re: Creating new indicator MACD Zero Lag

Hey Footon,

Thank you so much for the pointer to MACDHistogram.cs, I used it as a template for MACD Zero Lag.
Here it is, attached.

I don't know if I did it right (I still need to compare to the original indicator for MT4).
Also, I'd like to add 2 options for opening positions (MACD ZR histogram is higher than 0 / lower than 0). I believe that it is with "MACD Zero Lag histogram is higher/lower than the Level line", but not sure, since this is not documented in the original MACDHistogram.cs code I used.

Laurent

Post's attachments

MACD Zero Lag.cs 16.51 kb, 3 downloads since 2016-01-31 

You don't have the permssions to download the attachments of this post.

Re: Creating new indicator MACD Zero Lag

If indi works and the values matches with MT then you have done well!

For your requested logics, higher/lower than zero line, you can use the higher/lower than level, level is a numerical parameter, which is settable by the user. If you keep it as zero, the level line is zero (line).

If you want to use the macd and signal lines, turn to the macd.cs source, best would be to use the logics found in macd.cs and copy those in to your custom indi. Of course, you can make additional indi for macd and signal lines as well (like the standard macd and macd histogram in fsb).

Currently I cannot test your work myself as my ISP is playing up.

I don't know any current manual for custom indi creation for fsb, so if you strike a wall or have questions, post them freely and we'll try to help.

Good luck!

Re: Creating new indicator MACD Zero Lag

Hi Footon,

Thank you for the pointers to MACDHistogram and MACD code.
I quickly reviewed the MACD.cs code and I think I got the answers to my last questions.
I've tried my MACD Zero Lag indi and it seems to work.

I'll update my code with the last params I want to include (based upon MACD.cs) and do my due diligence to make sure the indi work as the MT4 one and I'll then post it for everybody to use it.

Last question: how should I post the indi when it works?

Thanks
Laurent


Laurent

Re: Creating new indicator MACD Zero Lag

You can always post it as an attachment in the forum, but it would be even better to upload the indi to the repository. You can find it here - http://forexsb.com/repository/repository_indicators/

Re: Creating new indicator MACD Zero Lag

OK, duly noted, will do.

Is there any kind of validation process first to ensure that quality of uploaded indis is up to some kind of standard?

Re: Creating new indicator MACD Zero Lag

No, currently no standardization process. When problems arise, then there are usually reports in the forum, and some bugs appear only when a group of people lay their hands on and one of them discovers something. To generalize, there are 2 types of bugs which are more frequent. Firstly, a crash due to out of bounds or overflow error; secondly, a trade error like no openings or false openings.

Re: Creating new indicator MACD Zero Lag

Hi Footon,

Thank you for pointing me out in the right direction, I finished the MACD Zero Lag indi (added MQL code and did some testing to make sure it's correct).
I posted it to the indicators repository, as you suggested.

Laurent

Re: Creating new indicator MACD Zero Lag

Hey Laurent,

No problems, glad to hear you have successfully completed your first project, well done! And thank you for widening the choice of custom indis!

Trade safe!
F