View Single Post
  #20 (permalink)  
Old 25th January 2010, 08:20
Enivid's Avatar
Enivid Enivid is online now
Administrator
 
Join Date: Nov 2008
Posts: 1,542
Thanks: 18
Thanked 20 Times in 16 Posts
Default

1. With iMA() function you get only indicator handle, not the buffer. You should copy the buffer to get the actual vales:

MQL5 Code:
  double MA1Buffer[];
   CopyBuffer(MA1, 0, 0, rates_total, MA1Buffer);
  double MA2Buffer[];
   CopyBuffer(MA2, 0, 0, rates_total, MA2Buffer);

Do this inside your OnCalculate() handler.

2. Then you need compare the buffer values rather than handles when determining the arrow. You also need to give your arrow buffers the actual values rather than just stating them:
MQL5 Code:
 if (MA2Buffer[i]>MA1MABuffer[i]);
     {Arrow1[i] = MA2Buffer[i]; }
 
 if (MA2Buffer[i]<MA1Buffer[i]);
    {Arrow2[i] = MA2Buffer[i]; }

3. When you have this working you may want to modify this code to draw arrows only on MA cross, not on all bars, but I don't know if that's relevant for you.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote