Author: Copyright � 2004, MetaQuotes Software Corp.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
3 Views
0 Downloads
0 Favorites
5_34_5_v3
//+------------------------------------------------------------------+
//|                                                   5_34_5.mq4     |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "Conversion from MQII perky_z@yahoo.com"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightBlue
#property indicator_color2 Red
//---- input parameters
int shift=0, loopbegin=0, prevbars=0;
double FastMA=0, SlowMA=0, prev=0;
bool first=true;
//---- buffers
double TrendBuffer[];
double LoBuffer[];
double Ma534=0, Ma534_1=0,Ma534_2=0,Ma534_3=0,Ma534_4=0,Ma534_5=0 ;
int CB=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- 3 additional buffers are used for counting.
   IndicatorBuffers(3);
//---- indicator buffers
   SetIndexBuffer(0,TrendBuffer);
   SetIndexBuffer(1,LoBuffer);
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1,LightBlue);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1,Red);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("5_34_5");
   //SetIndexDrawBegin(0,TrendBuffer);
   //SetIndexDrawBegin(1,LoBuffer);
   return(0);
  }
//+------------------------------------------------------------------+
//| Average Directional Movement Index                               |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0)  return(-1);
   if(counted_bars > 0)   counted_bars--;
   int limit = Bars - counted_bars;
   if(counted_bars==0) limit--;
      
   for(CB=limit;CB>=0; CB--)
     {
      // iMA(NULL,0,55,0,MODE_EMA,PRICE_CLOSE,0)
      Ma534=iMA(NULL,0,5,0,MODE_SMA, PRICE_MEDIAN,CB)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,CB);
      //if CB>=1 then 
      Ma534_1=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,CB)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,CB);
      //if CB>=2 then 
      Ma534_2=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,CB-1)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,CB-1);
      //if CB>=3 then 
      Ma534_3=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,CB-2)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,CB-2);
      //if CB>=4 then 
      Ma534_4=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,CB-3)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,CB-3);
      //if CB>=5 then 
      Ma534_5=iMA(NULL,0,5,0,MODE_SMA,PRICE_MEDIAN,CB-4)-iMA(NULL,0,34,0,MODE_SMA,PRICE_MEDIAN,CB-4);
      //SetIndexValue(CB,Ma534);
      //if CB>5 then
      //SetIndexValue2(CB,(Ma534_1+Ma534_3+Ma534_2+Ma534_4+Ma534_5)/5);
      //Ma5345=iMA(0,MODE_SMA,CB);
      //SetIndexValue2(CB,Ma5345);
      TrendBuffer[CB]=Ma534;
      LoBuffer[CB]=((Ma534_1+Ma534_3+Ma534_2+Ma534_4+Ma534_5)/5);
     }
   return(0);
  }
       // prevent to previous bars recounting
//+------------------------------------------------------------------+a534_3+Ma534_2+Ma534_4+Ma534_5)/5);
      //Ma5345=iMA(0,MODE_SMA,CB);
      //SetIndexValue2(CB,Ma5345);
      TrendBuffer[CB]=Ma534;
      LoBuffer[CB]=((Ma534_1+Ma534_3+Ma534_2+Ma534_4+Ma534_5)/5);
      //loopbegin = loopbegin-1; // prevent to previous bars recounting
     }
  return(0);
  }
   
       // prevent to previous bars recounting
//+------------------------------------------------------------------+

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 ---