ForceUSD_Chart

Author: Yuriy Tokman (YTG)
Price Data Components
Series array that contains open prices of each barSeries array that contains close prices for each bar
Miscellaneous
Implements a curve of type %1
2 Views
0 Downloads
0 Favorites
ForceUSD_Chart
//+------------------------------------------------------------------+
//|                                               ForceUSD_Chart.mq4 |
//|                                               Yuriy Tokman (YTG) |
//|                                               http://ytg.com.ua/ |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link      "http://ytg.com.ua/"
#property version   "1.00"
#property strict
#property indicator_chart_window

#property indicator_buffers 2
#property indicator_color1 clrRed
#property indicator_color2 clrGreen
#property indicator_width1 2
#property indicator_width2 2
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
string name="";
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   name = "ForceUSD_Chart";
   IndicatorShortName(name);
   
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexLabel(0,name);  
   
   SetIndexStyle(1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexLabel(1,name);   
//---
   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[])
  {
//---
double eur=0, gbp=0, jpy=0, chf=0;

   int limit=rates_total-prev_calculated;
   if(prev_calculated==0)limit--;
   else  limit++;
   for( int i=limit; i>=0 && !IsStopped(); i--)
    {
     eur = (iClose("EURUSD",0,i)-iOpen("EURUSD",0,i))/MarketInfo("EURUSD",MODE_POINT);
     gbp = (iClose("GBPUSD",0,i)-iOpen("GBPUSD",0,i))/MarketInfo("GBPUSD",MODE_POINT);
     jpy = (iClose("USDJPY",0,i)-iOpen("USDJPY",0,i))/MarketInfo("USDJPY",MODE_POINT);     
     chf = (iClose("USDCHF",0,i)-iOpen("USDCHF",0,i))/MarketInfo("USDCHF",MODE_POINT);          
     ExtMapBuffer1[i] = Open[i];
     ExtMapBuffer2[i] =Open[i] + ((eur + gbp - jpy - chf)/4)*Point;
    }    
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

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