诚信为本
量力而为
当前位置:峰汇在线 > MetaTrader 4 > MT4指标 > 正文

货币指数指标 MIndex.mq4

MIndex指标计算 USD, EUR, GBP, CHF, AUD, CAD 货币指数, 并在单独窗口里显示参数里指定的指数。

图表:MIndex指标

源码:

//+------------------------------------------------------------------+
//|                                                        MIndex.mq4|
//|                                    Copyright @2005, Yuri Makarov.|
//+------------------------------------------------------------------+
#property copyright "Copyright @2005, Yuri Makarov."
#property link      "http://www.125808047.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 OrangeRed

extern string Curency = "USD";

double EurUsd[],UsdChf[],GbpUsd[],UsdJpy[],AudUsd[],UsdCad[];
double Idx[];

int OnInit(void)
{
   IndicatorShortName(Curency);
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,Idx);
   Comment("www.125808047.com");
  return(INIT_SUCCEEDED);
}

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[])
  {
   ArrayCopySeries(EurUsd,MODE_CLOSE,"EURUSD");
   ArrayCopySeries(GbpUsd,MODE_CLOSE,"GBPUSD");
   ArrayCopySeries(AudUsd,MODE_CLOSE,"AUDUSD");
   ArrayCopySeries(UsdChf,MODE_CLOSE,"USDCHF");
   ArrayCopySeries(UsdJpy,MODE_CLOSE,"USDJPY");
   ArrayCopySeries(UsdCad,MODE_CLOSE,"USDCAD");

   int counted_bars=IndicatorCounted();
   double USD;

   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   int limit=Bars-counted_bars;
   for(int i=0; i<limit; i++)
   {
      USD = MathPow(UsdChf[i]*UsdJpy[i]*UsdCad[i]/EurUsd[i]/GbpUsd[i]/AudUsd[i],1./7.);
      if (Curency == "USD") Idx[i] = USD; 
      if (Curency == "EUR") Idx[i] = USD*EurUsd[i];
      if (Curency == "GBP") Idx[i] = USD*GbpUsd[i];
      if (Curency == "AUD") Idx[i] = USD*AudUsd[i];
      if (Curency == "CHF") Idx[i] = USD/UsdChf[i];
      if (Curency == "JPY") Idx[i] = USD/UsdJpy[i];
      if (Curency == "CAD") Idx[i] = USD/UsdCad[i];
   }
return(rates_total);
}
打赏
版权所有转载请注明标题及链接:峰汇在线 » 货币指数指标 MIndex.mq4
上一篇:
下一篇:
分享到: 更多 (0)

如您觉得此文不错请扫码打赏!

支付宝扫一扫打赏

微信扫一扫打赏