Author: Copyright � 2009, Bookkeeper
SRCx2MA
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
SRCx2MA
//+------------------------------------------------------------------+
//|                                                      SRCx2MA.mq4 |
//+------------------------------------------------------------------+
//  Íåîáõîäèìî íàëè÷èå SRCma.mq4
//  Presence SRCma.mq4 is necessary 
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, Bookkeeper"
#property link      "yuzefovich@gmail.com"
//----
#property  indicator_separate_window
#property  indicator_buffers 4
#property  indicator_color1  Aqua
#property  indicator_color2  Red
#property  indicator_color3  Blue
#property  indicator_color4  Maroon
//----
extern int IndPeriod1=3;
extern int IndPeriod2=10;
extern int CalculatedBars=500;
extern int rangeN=14;
extern int MAPeriod=13;

double   up_buffer1[];
double   dn_buffer1[];
double   up_buffer2[];
double   dn_buffer2[];
double   ind_buffer1[];
double   ind_buffer2[];
double   ind_buffer3[];

//+------------------------------------------------------------------+
int init()
{
   IndicatorBuffers(7);
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexStyle(3,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexBuffer(0,up_buffer1);
   SetIndexBuffer(1,dn_buffer1);
   SetIndexBuffer(2,up_buffer2);
   SetIndexBuffer(3,dn_buffer2);
   SetIndexBuffer(4,ind_buffer1);
   SetIndexBuffer(5,ind_buffer2);
   SetIndexBuffer(6,ind_buffer2);
   return(0);
}
//+------------------------------------------------------------------+
int deinit()
{
   return(0);
}
//+------------------------------------------------------------------+
int start()
{
   int  limit, i, counted_bars = IndicatorCounted();
   if(counted_bars < 0) 
       return(-1);
   if(counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars;
   if(CalculatedBars<500) CalculatedBars=500;
   if(limit>CalculatedBars) limit=CalculatedBars;
   for(i=limit;i>=0;i--)
   { 
      double Ind1=iCustom(NULL,0,"SRCma",CalculatedBars+IndPeriod2+1,rangeN,IndPeriod1,1,i);
      double Ind2=iCustom(NULL,0,"SRCma",CalculatedBars+IndPeriod2+1,rangeN,IndPeriod2,1,i);
      ind_buffer2[i]=Ind1-Ind2;
      ind_buffer3[i]=iMAOnArray(ind_buffer2,0,MAPeriod,0,MODE_SMA,i);
      ind_buffer1[i]=ind_buffer2[i]-ind_buffer3[i];
      if(ind_buffer1[i]>0)
      {
         dn_buffer1[i]=0;
         dn_buffer2[i]=0;
         if(ind_buffer1[i]>=ind_buffer1[i+1])
         {
            up_buffer1[i]=ind_buffer1[i];
            up_buffer2[i]=0;
         }
         else
         {
           up_buffer1[i]=0;
           up_buffer2[i]=ind_buffer1[i];
         }
      }
      else
      {
         up_buffer1[i]=0;
         up_buffer2[i]=0;
         if(ind_buffer1[i]<=ind_buffer1[i+1])
         {
            dn_buffer1[i]=ind_buffer1[i];
            dn_buffer2[i]=0;
         }
         else
         {
            dn_buffer1[i]=0;
            dn_buffer2[i]=ind_buffer1[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 ---