Download MetaTrader 5

Sloping MA

To add comments, please log in or register
Trade like successful traders - subscribe to their signals!
50592646
5
50592646 2011.07.03 03:02 

I'm reasonably new to this, therefore it may be staring me in the face, but as of yet I've had no luck finding the information.  

 What I want to do is have Moving averages 8, 20, 50, 200 have crossover signals for the 8, 20 - but I only want the trade to take place IF the MA(200) and the MA(50) are sloping upward (if long) and downward if short.

 Love any suggestions on this one.

 

Thanks 

Travis Silvers
162
Travis Silvers 2011.07.08 00:37  

So assuming you have used the iMA call to get a handle to your Moving Averages. You might end up with something like:

double ma200[2];

double ma50[2];

CopyBuffer(iMa200Handle,0,0,2,ma200);

CopyBuffer(iMa50Handle,0,0,2,ma50);

//Get the slope of ma200

double slopeMa200 = ma200[0] - ma200[1];

double slopeMa50 = ma50[0] - ma50[1];

 Now that you have the slopes you should be able to continue.

Alternatively if you have used CiMA and the associated Create method like in the How to Create a Module of Trading Signals then you might have something like:

In your Class definition 

protected: 

CiMA m_MA200;

CiMA m_MA50;

protected:

double MA200(int index){return (m_MA200.Main(index));} 

double MA50(int index){return (m_MA50.Main(index));}  

Initialize like in the article mentioned above

Then in your logic checking for open or close you would use something like:

MA200(1) > MA200(2) //Increasing

MA50(1) < MA50(2) //Decreasing 

In the appropriate logical spots.

Hope that helps. 

To add comments, please log in or register