//+------------------------------------------------------------------+ //| ForceUSD.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_separate_window #property indicator_buffers 1 #property indicator_color1 clrDarkViolet //---- buffers double ExtMapBuffer1[]; string name=""; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping name = "ForceUSD"; IndicatorShortName(name); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(0,ExtMapBuffer1); SetIndexLabel(0,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] = eur + gbp - jpy - chf; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+