MA ribbon filled mtf

Author: mladen
MA ribbon filled mtf
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
MA ribbon filled mtf
//+------------------------------------------------------------------+
//|                                                    MA ribbon.mq4 |
//|                                               mladenfx@gmail.com |
//|                                                                  |
//| original idea by Jose Silva                                      |
//+------------------------------------------------------------------+
#property copyright "mladen"
#property link      "mladenfx@gmail.com"

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_color1 C'0,70,0'
#property indicator_color2 C'70,0,0'
#property indicator_color3 Red
#property indicator_color4 Green
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 2
#property indicator_width4 2

//
//
//
//
//

extern int       MA1Period        = 13;
extern int       MA1Method        = MODE_LWMA;
extern int       MA1Price         = PRICE_CLOSE;
extern int       MA2Period        = 26;
extern int       MA2Method        = MODE_LWMA;
extern int       MA2Price         = PRICE_CLOSE;
extern int       TimeFrame        = 0;
extern string    note_TimeFrames_ = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-currentTF";

//
//
//
//
//

double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
string IndicatorFileName;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
//
//
//
//
//

int init()
{
   string short_name;
   SetIndexBuffer(0,buffer3); SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(1,buffer4); SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(2,buffer1);
   SetIndexBuffer(3,buffer2);
   switch(TimeFrame)
   {
   case 1: string TimeFrameStr = "M1" ;  break;
   case 5     :   TimeFrameStr = "M5" ;  break;
   case 15    :   TimeFrameStr = "M15";  break;
   case 30    :   TimeFrameStr = "M30";  break;
   case 60    :   TimeFrameStr = "H1" ;  break;
   case 240   :   TimeFrameStr = "H4" ;  break;
   case 1440  :   TimeFrameStr = "D1" ;  break;
   case 10080 :   TimeFrameStr = "W1" ;  break;
   case 43200 :   TimeFrameStr = "MN1";  break;
   default :      TimeFrameStr = "TF0";
   }

   TimeFrame         = MathMax(TimeFrame,Period());
   IndicatorFileName = WindowExpertName();
   short_name=("Ma Ribbon Filled("+TimeFrameStr+")") ;
   IndicatorShortName(short_name);
   return(0);
}
int deinit()
{
   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;
           
   if (TimeFrame != Period())
   {
      limit = MathMax(limit,TimeFrame/Period());
      for(i=0; i<limit; i++)
      {
         int y = iBarShift(NULL,TimeFrame,Time[i]);
            buffer1[i]  = iCustom(NULL,TimeFrame,IndicatorFileName,MA1Period,MA1Method,MA1Price,MA2Period,MA2Method,MA2Price,0,y);  
            buffer2[i]  = iCustom(NULL,TimeFrame,IndicatorFileName,MA1Period,MA1Method,MA1Price,MA2Period,MA2Method,MA2Price,1,y); 
            buffer3[i]  = iCustom(NULL,TimeFrame,IndicatorFileName,MA1Period,MA1Method,MA1Price,MA2Period,MA2Method,MA2Price,2,y);
            buffer4[i]  = iCustom(NULL,TimeFrame,IndicatorFileName,MA1Period,MA1Method,MA1Price,MA2Period,MA2Method,MA2Price,3,y); 
      }
   return(0);         
  }       

   //
   //
   //
   //
   //

   for(i=limit; i>=0; i--)
   {
      buffer1[i] = iMA(NULL,0,MA1Period,0,MA1Method,MA1Price,i);
      buffer2[i] = iMA(NULL,0,MA2Period,0,MA2Method,MA2Price,i);
      buffer3[i] = buffer1[i];
      buffer4[i] = buffer2[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 ---