trender_mtf

Author: Copyright � 2010, Yury Zinoviev
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
trender_mtf
//+------------------------------------------------------------------+
//|                                                      trender.mq4 |
//|                                  Copyright © 2010, Yury Zinoviev |
//|                                          zinoviev.yury@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, Yury Zinoviev"
#property link      "zinoviev.yury@gmail.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Green

//---- buffers
double g1[];

//inputs
extern double tf=0;
extern int ma_type=1;
extern int ma_price=0;
extern int ma_start=10;
extern int ma_end=175;
extern int ma_step=5;

extern int flat=100;

int dg;
double r;

int init()
  {
   SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,2);
   SetIndexBuffer(0,g1);
   SetIndexLabel(0,"trend hysto " + tf);
   SetLevelValue(0,0);
   SetLevelValue(0,flat);
   SetLevelValue(1,(-1*flat));
   IndicatorShortName("trend hystogramm");
      dg=mult(Symbol());
      if(tf!=0)r=tf/Period();else r=1;

   return(0);
  }



int deinit()
  {


   return(0);
  }



int start()
  {
   int i,j,k;
   int    counted_bars;
   double ma,ma2,matotal;
   
   string sy=Symbol();
   double pnt=MarketInfo(sy,MODE_POINT);

   counted_bars=IndicatorCounted();
   
   i=Bars-counted_bars-1; 
   
   
   while(i>=0)
   {
      k=ma_start; matotal=0;
      ma=iMA(sy,tf,k,0,ma_type,ma_price,MathFloor(i/r));
      while(k<ma_end)
         {
         int ii=MathFloor(i/r);
         k+=ma_step;
         ma2=iMA(sy,tf,k,0,ma_type,ma_price,ii);
         matotal+=(ma-ma2);
         ma=ma2;
         }
         
      g1[i]=matotal/pnt/dg;
      //Comment(matotal/pnt+"\n"+ma2);
      i--;
      
   }

   return(0);
  }
//+------------------------------------------------------------------+
int mult(string symb)
 {
   int x = 1;
   //if(!AutoDigits) return(x);
   int v=int(MarketInfo(symb,MODE_DIGITS));
   switch (v)       
    {
     case 2:    x=1;  break;
     case 4:    x=1;  break;
     case 3:    x=10; break;
     case 5:    x=10; break;
     default  : x=1; 
    }
   return(x);
 }  

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