Author:
ma_x2_roc
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites
ma_x2_roc
//+------------------------------------------------------------------+
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
//2009fxtsd ma x2
#property copyright ""
#property link      ""

#property indicator_separate_window
#property indicator_buffers    2
#property indicator_color1     Blue
#property indicator_color2     Red

//#property indicator_width1     1

#property indicator_level1      0.03
#property indicator_level2     -0.03
#property indicator_levelcolor DarkSlateGray




extern int ma1period      = 7;
extern int ma1method      = 1;
extern int ma1price       = 0;

extern int ma2period      = 13;
extern int ma2method      = 1;
extern int ma2price       = 0;

extern int slopePeriod=1;


double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int init()
{
      IndicatorBuffers(4); 

   
   SetIndexBuffer(0,buffer1);
   SetIndexBuffer(1,buffer2);
   SetIndexBuffer(2,buffer3);
   SetIndexBuffer(3,buffer4);

   IndicatorShortName("2ma roc " );  
   SetIndexLabel(0,"ma1 "+ma1period);
   SetIndexLabel(1,"ma2"+ma2period);



   return(0);
}


//+------------------------------------------------------------------+


int start()
{
   int counted_bars=IndicatorCounted();
   int limit,i;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;


   for(i=limit; i>=0; i--)
   {
     buffer3[i]  = iMA(NULL, 0, ma1period, 0,ma1method, ma1price, i); 
     buffer4[i]  = iMA(NULL, 0, ma2period, 0,ma2method, ma2price, i); 


         if (buffer3[i]&&buffer4[i]!=0)
         {
          buffer1[i]=100*(buffer3[i]-buffer3[i+slopePeriod])/buffer3[i];
          buffer2[i]=100*(buffer4[i]-buffer4[i+slopePeriod])/buffer4[i];
          }
   
  }
   
   return(0);
}


Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---