NYBOT Index

Author: Stanislav Aksenov
Price Data Components
Series array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
NYBOT Index
//+------------------------------------------------------------------+
//|                                                  NYBOT Index.mq4 |
//|                                                Stanislav Aksenov |
//|                       https://www.mql5.com/ru/users/stasikusssss |
//+------------------------------------------------------------------+
#property copyright "Stanislav Aksenov"
#property link      "https://www.mql5.com/ru/users/stasikusssss"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 clrRed

input int historyBars = 1000;
input double turnoverEUR = 57.6;
input double turnoverGBP = 11.9;
input double turnoverCHF = 3.6;
input double turnoverJPY = 13.6;
input double turnoverCAD = 9.1;
input double turnoverSEK = 4.2;
input string symbEURUSD = "EURUSD";
input string symbGBPUSD = "GBPUSD";
input string symbUSDCHF = "USDCHF";
input string symbUSDJPY = "USDJPY";
input string symbUSDCAD = "USDCAD";
input string symbUSDSEK = "USDSEK";
input double multiplier = 50.0;
input int digitsInd = 2;

double buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,buffer);
   SetIndexStyle(0,DRAW_LINE);
   IndicatorShortName("NYBOT Index ("+tf(Period())+")");     
   IndicatorDigits(digitsInd);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int limit = 0;
   if(Bars<historyBars) limit = Bars; else limit = historyBars;
   for(int i=0; i<limit; i++) {
         double cls;
         double USDEUR = 0.0; double USDGBP = 0.0; double USDCHF = 0.0; double USDJPY = 0.0; double USDCAD = 0.0; double USDSEK = 0.0;
         if(symbEURUSD!="") {
            cls = iClose(symbEURUSD,Period(),i);
            if(cls>0.0) USDEUR = 1.0 / cls;
         }
         if(symbGBPUSD!="") {
            cls = iClose(symbGBPUSD,Period(),i);
            if(cls>0.0) USDGBP = 1.0 / cls;
         }
         if(symbUSDCHF!="") USDCHF = iClose(symbUSDCHF,Period(),i);
         if(symbUSDJPY!="") USDJPY = iClose(symbUSDJPY,Period(),i);
         if(symbUSDCAD!="") USDCAD = iClose(symbUSDCAD,Period(),i);
         if(symbUSDSEK!="") USDSEK = iClose(symbUSDSEK,Period(),i);
         buffer[i] = multiplier*MathPow(USDEUR,turnoverEUR/100.0)*MathPow(USDGBP,turnoverGBP/100.0)*MathPow(USDCHF,turnoverCHF/100.0)*
            MathPow(USDJPY,turnoverJPY/100.0)*MathPow(USDCAD,turnoverCAD/100.0)*MathPow(USDSEK,turnoverSEK/100.0);       
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
string tf(int per)
 {
  if(per==1) return("M1");
  if(per==5) return("M5");
  if(per==15) return("M15");
  if(per==30) return("M30");
  if(per==60) return("H1");
  if(per==240) return("H4");
  if(per==1440) return("D1");
  if(per==10080) return("W1");
  if(per==43200) return("MN"); 
  return(""); 
 }
//**********************************************************************

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