i-MN1_W1_D1_HLM

Author: Copyright � 2009, MetaQuotes Software Corp.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
i-MN1_W1_D1_HLM
//+------------------------------------------------------------------+
//|                                              i-MN1_W1_D1_HLM.mq4 |
//|                      Copyright © 2010, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.mql4.com/ru/users/costy_"

#property indicator_chart_window
#property indicator_buffers 8

//----
double ma1_buffer[],
ma2_buffer[],
ma3_buffer[],
ma4_buffer[],
ma5_buffer[],
ma6_buffer[],
ma7_buffer[],
ma8_buffer[],
buffers_all[8];
string name[12];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   for(int i=0; i<=11; i++)
      name[i]="Label"+MathRand();

   SetIndexBuffer(0,ma1_buffer);
   SetIndexBuffer(1,ma2_buffer);
   SetIndexBuffer(2,ma3_buffer);
   SetIndexBuffer(3,ma4_buffer);
   SetIndexBuffer(4,ma5_buffer);
   SetIndexBuffer(5,ma6_buffer);
   SetIndexBuffer(6,ma7_buffer);
   SetIndexBuffer(7,ma8_buffer);
   return(0);
  }
//+------------------------------------------------------------------+
int deinit()
  {
   for(int i=0; i<=11; i++)
      ObjectDelete(name[i]);
   return(0);
  }
//+------------------------------------------------------------------+
int start()
  {

   SetIndexStyle(0,DRAW_ARROW,EMPTY,2,Orange);
   SetIndexStyle(1,DRAW_ARROW,EMPTY,5,Blue);
   for(int i=3; i>=2; i--)
      SetIndexStyle(i,DRAW_ARROW,EMPTY,i,Orange);
   for(i=5; i>=4; i--)
      SetIndexStyle(i,DRAW_ARROW,EMPTY,i,Blue);
   for(i=7; i>=6; i--)
      SetIndexStyle(i,DRAW_ARROW,EMPTY,i,Green);
   for(i=7; i>=0; i--)
      SetIndexArrow(i,160);

//----  
   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(i=0; i<=limit; i++)
     {
      ma1_buffer[i] = iMA(Symbol(), PERIOD_D1 , 1, 0, 0, 4, iBarShift(0,PERIOD_D1,Time[i])+1);
      ma2_buffer[i] = iMA(Symbol(), PERIOD_W1 , 1, 0, 0, 4, iBarShift(0,PERIOD_W1,Time[i])+1);
      ma3_buffer[i] = iMA(Symbol(), PERIOD_D1 , 1, 0, 0, 2, iBarShift(0,PERIOD_D1,Time[i])+1);
      ma4_buffer[i] = iMA(Symbol(), PERIOD_D1 , 1, 0, 0, 3, iBarShift(0,PERIOD_D1,Time[i])+1);
      ma5_buffer[i] = iMA(Symbol(), PERIOD_W1 , 1, 0, 0, 2, iBarShift(0,PERIOD_W1,Time[i])+1);
      ma6_buffer[i] = iMA(Symbol(), PERIOD_W1 , 1, 0, 0, 3, iBarShift(0,PERIOD_W1,Time[i])+1);
      ma7_buffer[i] = iMA(Symbol(), PERIOD_MN1, 1, 0, 0, 2, iBarShift(0,PERIOD_MN1,Time[i])+1);
      ma8_buffer[i] = iMA(Symbol(), PERIOD_MN1, 1, 0, 0, 3, iBarShift(0,PERIOD_MN1,Time[i])+1);
     }
//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ     
//Ðèñóåì ñ áîêó îò ëèíèé òåêñò ìåòêè
   buffers_all [0] =  ma1_buffer[0];   buffers_all [1] =  ma2_buffer[0];
   buffers_all [2] =  ma3_buffer[0];   buffers_all [3] =  ma4_buffer[0];
   buffers_all [4] =  ma5_buffer[0];   buffers_all [5] =  ma6_buffer[0];
   buffers_all [6] =  ma7_buffer[0];   buffers_all [7] =  ma8_buffer[0];

   for(i=0; i<=7; i++)
      if(ObjectFind(name[i])<0)
         ObjectCreate(name[i],OBJ_TEXT,0,Time[0]+16,buffers_all[i]);
   for(i=0; i<=7; i++)
      ObjectMove(name[i],0,Time[0]+16,buffers_all[i]);
   ObjectSetText(name[0],"                  Median D1",10,"Times New Roman",Orange);
   ObjectSetText(name[1],"                  Median W1",10,"Times New Roman",Blue);
   ObjectSetText(name[2],"                  High D1",10,"Times New Roman",Orange);
   ObjectSetText(name[3],"                  Low D1",10,"Times New Roman",Orange);
   ObjectSetText(name[4],"                  High W1",10,"Times New Roman",Blue);
   ObjectSetText(name[5],"                  Low W1",10,"Times New Roman",Blue);
   ObjectSetText(name[6],"                  High MN1",10,"Times New Roman",Green);
   ObjectSetText(name[7],"                  Low MN1",10,"Times New Roman",Green);

//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ     
//Ðèñóåì ãîðèç ëèíèè ñðåäíèõ çíà÷
   if(ObjectFind(name[11])<0)
      ObjectCreate(name[11],OBJ_HLINE,0,0,(buffers_all[6]+buffers_all[7])/2);

   ObjectSet(name[11],OBJPROP_PRICE1,(buffers_all[6]+buffers_all[7])/2);

   ObjectSet(name[11],OBJPROP_COLOR,Green);

   ObjectSet(name[11],OBJPROP_WIDTH,8);

   ObjectSetText(name[11],"Median MN1",10,"Times New Roman",Green);
   for(i=0; i<=7; i++)
      ObjectMove(name[i],0,Time[0]+16,buffers_all[i]);

//ææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææææ     

   Comment("Spread  "+DoubleToStr((Ask-Bid)/Point,0));
   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 ---