SayaBarCrossView

Author: Copyright 2011 Masaru.Sasaki
SayaBarCrossView
Price Data Components
Series array that contains close prices for each barSeries array that contains close prices for each bar
Indicators Used
Moving average indicator
0 Views
0 Downloads
0 Favorites
SayaBarCrossView
//+------------------------------------------------------------------+
//|                                             SayaBarCrossView.mq4 |
//|                                     Copyright 2011 Masaru.Sasaki |
//|                                      http://youtarou.blogzine.jp |
//+------------------------------------------------------------------+
#property copyright "Copyright 2011 Masaru.Sasaki"
#property link      "http://youtarou.blogzine.jp"

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow
#property indicator_level1 0

// parameters
extern string SetCurrency = "CHFJPY"; // AUDJPY default
extern int Ma_mode = MODE_SMA;
extern int SmoothMa = 43;

// buffers
double Sayabuf[];
double SayaMabuf[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
{
   // Symbol check
   if( StringLen(Symbol()) > 6 )
   {
      SetCurrency = SetCurrency+StringSubstr(Symbol(),6, StringLen(Symbol())-6);
   }
   
   SetIndexBuffer(0, Sayabuf);
   SetIndexBuffer(1, SayaMabuf);
   
   SetIndexLabel(0,SetCurrency+"[Saya]");
   SetIndexLabel(1,SetCurrency+"[SayaMA]");
   
   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
{

   return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   int limit=Bars-counted_bars;
   
   for(int i=limit-1; i>=0; i--)
   {
      Sayabuf[i] = MathAbs((Close[i]/Point)-(iClose(SetCurrency,0,i)/MarketInfo(SetCurrency,MODE_TICKSIZE)));
   }
   
   // Saya MA
   for(i=0; i<limit; i++)
   {
      SayaMabuf[i] = iMAOnArray(Sayabuf, Bars, SmoothMa, 0, Ma_mode, 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 ---