Forex
Google

Go Back   Forex Trading > Downloads > Indicators - Metatrader 4


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

 
 
LinkBack Thread Tools
 
Old 11-17-2007, 05:25 AM
daraknor's Avatar
Senior Member
 
Join Date: Oct 2006
Location: Portland, OR USA
Posts: 996
daraknor is on a distinguished road
Thumbs up New MACD - Accuracy?

I have a MACD version that is supposedly more accurate. It uses EMA for the signal calculation as well. I tried making the same MACD by modifying the MACD in MT4 but it is not coming up with the same numbers.

Can we port this over to MT4? I've been working on this for a long time, and I've labeled a few pieces but I don't know why they are doing some things.

Here is the *gasp gasp finally* source code to the version of MACD that I'd like to port over, written in Java:
Code:
    public static void a(float[] fs, int i, int i_47_, float f, float f_48_,
			 float f_49_, float[] fs_50_, float[] fs_51_,
			 float[] fs_52_) {  //f[],i,i,f,f,f,f[],f[],f[]
                 //history, counter1?, counter2?, param1, param2, paramSignal, line1, line2, lineSignal
        float f_53_ = 2.0F / (f + 1.0F);
        float f_54_ = 2.0F / (f_48_ + 1.0F);
        float f_55_ = 2.0F / (f_49_ + 1.0F);        //Is this how an EMA is made exponential?
        for (int i_56_ = 0; i_56_ <= i && i_56_ < i_47_; i_56_++) //counter less than i_47_
        {     //i_56_ is a bar counter? //i is number of bars to count
            fs_50_[i_56_] = 0.0F;   //is this zeroing out values? YES. Overwritten at end...
            fs_51_[i_56_] = 0.0F;
            fs_52_[i_56_] = 0.0F;
        }
	    if (i < i_47_) 
        {
            a(fs, i, i_47_, f_54_, (int) f_48_, fs_51_);        //Is that an MA? f[],i,i,f,i,f[]
            a(fs, i, i_47_, f_53_, (int) f, fs_52_);            //Is that an MA? f[],i,i,f,i,f[]
            for (int i_57_ = 0; i_57_ < i; i_57_++)
                fs_50_[i_57_] = 0.0F;       //Zero line on range
            for (int i_58_ = i; i_58_ < i_47_; i_58_++)
                fs_50_[i_58_] = fs_51_[i_58_] - fs_52_[i_58_];  //Calculates Signal line
            a(fs_50_, i + (int) f - 1, i_47_, f_55_, (int) f_49_, fs_51_);  //f[],i,i,f,i,f[]   //EMA on signal
            for (   int i_59_ = 0; 
                    i_59_ < i+ (int)f_48_ - 1; 
                    i_59_++
            )
                fs_52_[i_59_] = 0.0F;
            for (  int i_60_ = i+ (int)f_48_ - 1;
                    i_60_ < i_47_; 
                    i_60_++
            )
                fs_52_[i_60_] = fs_50_[i_60_] - fs_51_[i_60_];
            int i_61_ = i + (int) f + (int) f_49_ - 1;
            for (int i_62_ = 0; i_62_ < i_61_; i_62_++)     //WTF?
            {
                fs_50_[i_62_] = fs_50_[i_61_];
                fs_51_[i_62_] = fs_51_[i_61_];
                fs_52_[i_62_] = fs_52_[i_61_];
            }
        }
    }
    public static float[] a(float[] fs, int i, int i_91_, float f, int i_92_,
			    float[] fs_93_) { //THIS IS EMA //f[],i,i,f,i,f[]
                    //a(fs, i, i_47_, f_54_, (int) f_48_, fs_51_);
                    //a(fs, i, i_47_, f_53_, (int) f, fs_52_);
                    //a(fs_50_, i + (int) f - 1, i_47_, f_55_, (int) f_49_, fs_51_);
	if (fs_93_ == null || fs_93_.length < i_91_)
	    fs_93_ = new float[i_91_];
	if (i >= i_91_)
	    return fs_93_;
	float f_94_ = 0.0F;
	for (int i_95_ = i; i_95_ < i + i_92_ && i_95_ < i_91_; i_95_++)
	    f_94_ += fs[i_95_];
	fs_93_[i + i_92_ - 1] = f_94_ / (float) i_92_;
	for (int i_96_ = i + i_92_; i_96_ < i_91_; i_96_++)
	    fs_93_[i_96_] = (1.0F - f) * fs_93_[i_96_ - 1] + f * fs[i_96_];
	int i_97_ = i + i_92_ - 1;
	for (int i_98_ = 0; i_98_ < i_97_ && i_98_ < i_91_; i_98_++)
	    fs_93_[i_98_] = fs_93_[i_97_];
	return fs_93_;
    }
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 11-17-2007, 05:28 AM
daraknor's Avatar
Senior Member
 
Join Date: Oct 2006
Location: Portland, OR USA
Posts: 996
daraknor is on a distinguished road
This is probably pretty easy, but my brain is just fried at this point... I think the EMA is the same as the EMA used in MT4 but I'm not 100% certain since the prices are different.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 
Old 11-18-2007, 02:26 PM
Senior Member
 
Join Date: Jan 2007
Posts: 207
Poocher is on a distinguished road
Way to go Daraknor!!!

You never quit.

I'd love to check out any indicator you come up with.

If you don't get the response you want please give me the okay to spread your request to Forex Factory and other places (Neoticker forum) where there might be programmers grateful for your MACD who'll Mt4-it.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
 

Bookmarks
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SIMPLE-MACD-EA : An extremely simple EA based on 2 channels of MACD. Try it! investor_me Expert Advisors - Metatrader 4 31 07-30-2008 09:59 AM
Help with MACD and SAR robp Metatrader 4 0 09-11-2007 12:03 PM
Accuracy? AirforceMook Expert Advisors - Metatrader 4 1 02-06-2007 07:24 AM
macd signal and macd value cross boostrade Expert Advisors - Metatrader 4 1 02-04-2007 04:33 PM
MACD-WDD (MACD-Simple on GBPUSD) PluT0 Expert Advisors - Metatrader 4 1 12-18-2005 12:30 AM


All times are GMT. The time now is 09:13 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.