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

副图收盘价线指标 CurrencyChart.mq4

CurrencyChart指标可以在单独窗口绘制指定货币对的收盘价线。

图表:CurrencyChart指标

源码:

//+------------------------------------------------------------------+
//|                                                CurrencyChart.mq4 |
//|                                                          Strator |
//+------------------------------------------------------------------+
#property copyright "Strator"
#property link      "http://www.125808047.com"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 Green

extern string symbol = "EURUSD";

double buffer_close[];
bool exit = false;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
string StringUCase(string str)
  {
   for(int i = 0; i < StringLen(str); i++)
     {
       int char_1 = StringGetChar(str, i);
       if((char_1 >= 97 && char_1 <= 122) || (char_1 >= 224 && char_1 <= 255))
           char_1 = char_1 - 32;
       str = StringSetChar(str, i, char_1);
     }
   return(str);
  }
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
{
   symbol = StringUCase(symbol);
   MarketInfo(symbol, MODE_TIME);
   int last_error = GetLastError();
   if(last_error == 4106)
     {
       string msg = "" + symbol;
       IndicatorShortName(msg);
       Print(msg);
       exit = true;
     }
   else
     {
       IndicatorShortName(symbol + ",M" + Period());
       SetIndexBuffer(0, buffer_close);
       SetIndexStyle(0, DRAW_LINE);
       IndicatorDigits(MarketInfo(symbol, MODE_DIGITS));
     }
   Comment("www.125808047.com");
  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[])
  {
   if(exit) 
       return(0);
   int counted_bars = Bars - IndicatorCounted() - 1;
   for(int i = 0; i < counted_bars; i++)
     {
       datetime time_bar = Time[i];
       int bar_no = iBarShift(symbol, Period(), time_bar, false);
       buffer_close[i] = iClose(symbol, Period(), bar_no);
     }
   SetLevelStyle(DRAW_LINE, 1, DarkGray);
   SetLevelValue(0, MarketInfo(symbol, MODE_BID));
   return(rates_total);
  }
打赏
版权所有转载请注明标题及链接:峰汇在线 » 副图收盘价线指标 CurrencyChart.mq4
上一篇:
下一篇:
分享到: 更多 (0)

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

支付宝扫一扫打赏

微信扫一扫打赏