這是沒錯的
應該是你要的訴求跟你編的代碼有出入
這是沒錯的
應該是你要的訴求跟你編的代碼有出入
哈哈,谢谢回复。反正我测试的是有问题的,你自己也可以试试。
測試過是沒問題的 如果有問題早就一堆人提出來了
MT4跟MT5的編法不一樣 MT4能用不代表MT5能用 去查一下幫助文件
MT5 iClose执行不正确
====================testxx.mq5============
#property copyright "2009-2020, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Larry Williams' Accumulation/Distribution"
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_color1 LightSeaGreen
//--- indicator buffer
double ExtWADBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//--- define buffer
SetIndexBuffer(0,ExtWADBuffer);
//--- set draw begin
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0);
//--- indicator name
IndicatorSetString(INDICATOR_SHORTNAME,"xxx1");
//--- round settings
//IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
}
//+------------------------------------------------------------------+
//| 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(rates_total<2)
return(0);
//--- main cycle
for(int i=0; i<rates_total && !IsStopped(); i++)
{
ExtWADBuffer[i] = iClose("USDJPY",PERIOD_CURRENT, 1);
}
//--- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
上面的代码画出来的图形完全不对,客服人员自己运行一下就可以看到了
iClose函数,mt4和mt5的用法是一样的,区别是mt5的指标k线排序和mt4不同
#property copyright "2009-2020, MetaQuotes Software Corp." #property link "http://www.mql5.com" #property description "Larry Williams' Accumulation/Distribution" //--- indicator settings #property indicator_separate_window #property indicator_buffers 1 #property indicator_plots 1 #property indicator_type1 DRAW_LINE #property indicator_color1 LightSeaGreen //--- indicator buffer double ExtWADBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //--- define buffer SetIndexBuffer(0,ExtWADBuffer); //--- set draw begin PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0); //--- indicator name IndicatorSetString(INDICATOR_SHORTNAME,"xxx1"); //--- round settings //IndicatorSetInteger(INDICATOR_DIGITS,_Digits); ArraySetAsSeries(ExtWADBuffer,true); } //+------------------------------------------------------------------+ //| 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(rates_total<2) return(0); //--- main cycle for(int i=0; i<rates_total && !IsStopped(); i++) { ExtWADBuffer[i] = iClose("USDJPY",PERIOD_CURRENT, i); } //--- OnCalculate done. Return new prev_calculated. return(rates_total); } //+------------------------------------------------------------------+
大神直接給出答案了
MT5 iClose执行不正确
====================testxx.mq5============
#property copyright "2009-2020, MetaQuotes Software Corp."
#property link "http://www.mql5.com"
#property description "Larry Williams' Accumulation/Distribution"
//--- indicator settings
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots 1
#property indicator_type1 DRAW_LINE
#property indicator_color1 LightSeaGreen
//--- indicator buffer
double ExtWADBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
void OnInit()
{
//--- define buffer
SetIndexBuffer(0,ExtWADBuffer);
//--- set draw begin
PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,0);
//--- indicator name
IndicatorSetString(INDICATOR_SHORTNAME,"xxx1");
//--- round settings
//IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
}
//+------------------------------------------------------------------+
//| 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(rates_total<2)
return(0);
//--- main cycle
for(int i=0; i<rates_total && !IsStopped(); i++)
{
ExtWADBuffer[i] = iClose("USDJPY",PERIOD_CURRENT, 1);
}
//--- OnCalculate done. Return new prev_calculated.
return(rates_total);
}
//+------------------------------------------------------------------+
上面的代码画出来的图形完全不对,客服人员自己运行一下就可以看到了