ElderRaySystem

Author: Copyright � 2010, LeMan.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
ElderRaySystem
//+------------------------------------------------------------------+
//|                                               ElderRaySystem.mq4 |
//|                                         Copyright © 2010, LeMan. |
//|                                                 b-market@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, LeMan."
#property link      "b-market@mail.ru"

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Green
#property indicator_color2 Red
#property indicator_color3 Blue
#property indicator_width1 3
#property indicator_width2 3
//---- input parameters
extern bool      ShowSeason = true;
extern int       season = 21;
extern int       ray = 13;
//---- buffers
double UpBuffer[];
double DnBuffer[];
double Buffer[];
int p;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   IndicatorDigits(Digits);
   SetIndexStyle(0, DRAW_ARROW);
   SetIndexArrow(0,159);
   SetIndexBuffer(0, UpBuffer);
   SetIndexStyle(1, DRAW_ARROW);
   SetIndexArrow(1,159);
   SetIndexBuffer(1, DnBuffer);
   SetIndexStyle(2, DRAW_LINE);   
   SetIndexBuffer(2, Buffer);
   switch(Period()) {
      case 1:     p = 5;     break;
      case 5:     p = 30;    break;
      case 15:    p = 60;    break;
      case 30:    p = 240;   break;      
      case 60:    p = 240;   break;            
      case 240:   p = 1440;  break;  
      case 1440:  p = 10080; break;                      
      case 10080: p = 43200; break;      
      case 43200: p = 43200; break;            
  }

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {
   int i;
   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-=1+2;    
   
   for (i = 0; i < limit; i++) {
      UpBuffer[i] = 0;
      DnBuffer[i] = 0;
      int shift = iBarShift(NULL,p,iTime(NULL,0,i)); 
      double ma1 = iMA(NULL, 0, ray, 0, MODE_EMA, PRICE_CLOSE, i+1); 
      double ma2 = iMA(NULL, 0, ray, 0, MODE_EMA, PRICE_CLOSE, i+2); 
      double ma3 = iMA(NULL, p, season, 0, MODE_EMA, PRICE_CLOSE, shift+1); 
      double ma4 = iMA(NULL, p, season, 0, MODE_EMA, PRICE_CLOSE, shift+2);
      if (ma3 > ma4 && Low[i+2] < ma2 && Low[i+1] > ma1) {
         UpBuffer[i] = High[i+1]+10*Point;
      }
      if (ma3 < ma4 && High[i+2] > ma2 && High[i+1] < ma1) {
         DnBuffer[i] = Low[i+1]-10*Point;
      }
      if (ShowSeason == True) Buffer[i] = ma3;
   }
   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 ---