Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
Donch
ÿþ

#property strict

#property indicator_chart_window

#property indicator_buffers 5

#property indicator_color1 clrRed

#property indicator_color2 clrBlue

#property indicator_width1 1

#property indicator_width2 1

#property indicator_color3 clrYellow

//#property indicator_style3 STYLE_DOT

#property indicator_width3 1



#property indicator_color5 clrRed

#property indicator_color4 clrBlue

#property indicator_width5 2

#property indicator_width4 2



//---- input parameters

extern ENUM_APPLIED_PRICE Price=PRICE_CLOSE;

extern bool   DrawHL     =true;

extern bool   DrawMID    =true;  

extern bool   DrawUD     =true;  

extern int    Depth      =60;

extern bool   minutes    =false;//Depth in minutes

extern double deviation  =0;  

extern int    LIMIT=2000;





double up[],dn[],up1[],dn1[],mid[];





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

//| Custom indicator initialization function                         |

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

int init()

  {

   //if(Depth<3) Depth=3;

   if(LIMIT<Depth) LIMIT=Bars-Depth-2;

   SetIndexStyle(1,DrawHL?DRAW_LINE:DRAW_NONE);

   SetIndexBuffer(1,up);

   SetIndexStyle(0,DrawHL?DRAW_LINE:DRAW_NONE);

   SetIndexBuffer(0,dn);



   SetIndexStyle(2,DrawMID?DRAW_LINE:DRAW_NONE);

   SetIndexBuffer(2,mid);

   

   SetIndexStyle(3,DrawUD?DRAW_LINE:DRAW_NONE);

   SetIndexBuffer(3,up1);

   SetIndexStyle(4,DrawUD?DRAW_LINE:DRAW_NONE);

   SetIndexBuffer(4,dn1);



//----

   return(0);

  }

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

//| Custom indicator deinitialization function                       |

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

int deinit()

  {

//----

   return(0);

  }

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

//| Custom indicator iteration function                              |

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

int start()

  {

   int counted_bars=IndicatorCounted();

//----

   int i,

       limit=MathMax(MathMin(LIMIT,Bars-counted_bars),0);

//Print(limit);

   if(!minutes)

   for(i=limit; i>=0; i--)

    {

     up[i]=High[iHighest(NULL,0,MODE_HIGH,Depth,i)];

     dn[i]=Low [iLowest (NULL,0,MODE_LOW ,Depth,i)];

     mid[i]=(up[i]+dn[i])/2;

     if(DrawUD)

      {

       double pr=iMA(NULL,0,1,0,MODE_SMA,Price,i);

       if(pr>mid[i]+(up[i]-mid[i])*deviation) up1[i]=mid[i];

       if(pr<mid[i]-(up[i]-mid[i])*deviation) dn1[i]=mid[i];

      }

    }

    else

    for(i=limit; i>=0; i--)

    {

     int m;

     for(m=1;m+i<Bars;m++) {if((Time[i]-Time[m+i])/60>=Depth) break;}

     up[i]=High[iHighest(NULL,0,MODE_HIGH,m,i)];

     dn[i]=Low [iLowest (NULL,0,MODE_LOW ,m,i)];

     mid[i]=(up[i]+dn[i])/2;

     if(DrawUD)

      {

       double pr=iMA(NULL,0,1,0,MODE_SMA,Price,i);

       if(pr>mid[i]+(up[i]-mid[i])*deviation) up1[i]=mid[i];

       if(pr<mid[i]-(up[i]-mid[i])*deviation) dn1[i]=mid[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 ---