学着编指标,出点问题,找不到原因在哪 求兄弟们指教
问题一:K线换线,指标不会自动刷新,得切换一下周期才能跟上。问题二:第二跟指标红线显示不出来。
照葫芦画瓢的,没编程基础,根本不知道问题在哪,谁能给解释一下。可能问题很可笑,不对的地方可能很多,见谅
解答问题还要花金币?
你能直接把代码帖出来吗? 问题一:
试试
for(i=limit-1;i>0;i--)
问题二:
增加
#propertyindicator_color1Black
#propertyindicator_color2Green
和
#propertyindicator_color1Black
#propertyindicator_color2Green snfdf 发表于 2015-8-4 18:03
解答问题还要花金币?
你能直接把代码帖出来吗?
哪位兄弟有空帮忙修正一下这个指标里的错误
问题一:K线换线,指标不会自动刷新,得切换一下周期才能跟上。
问题二:加载后只有第一个buffer。第二个buffer无效
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots 2
//--- plot chuzhi
#property indicator_label1"chuzhi"
#property indicator_type1 DRAW_HISTOGRAM
#property indicator_color1clrGreen
#property indicator_style1STYLE_SOLID
#property indicator_width11
//--- plot junzhi
#property indicator_label2"junzhi"
#property indicator_type2 DRAW_LINE
#property indicator_color2clrRed
#property indicator_style2STYLE_SOLID
#property indicator_width21
//--- input parameters
input int zhouqi=24;
//--- indicator buffers
double chuzhiBuffer[];
double junzhiBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,chuzhiBuffer);
SetIndexBuffer(1,junzhiBuffer);
//---
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[])
{
//---
int i,limit;
limit=rates_total-prev_calculated;
if(prev_calculated>0)
limit++;
for(i=0;i<limit;i++)
{ chuzhiBuffer=(close+close+close)/3-close;
}
for(i=0;i<limit;i++)
{
junzhiBuffer=iMAOnArray(chuzhiBuffer, Bars, zhouqi, 0, MODE_SMA, i);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+
admin 发表于 2015-8-4 23:35
问题一:
试试
for(i=limit-1;i>0;i--)
谢谢~~不过没能解决
你这个代码错误太多了,你编译的时候难道没看到提示吗?你第一遍运行和以后运行的代码要分开写,你close数组都越界了,后面的代码当然就不执行了,当然后面的就都不显示了.
#property version "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots 2
//--- plot chuzhi
#property indicator_label1"chuzhi"
#property indicator_type1 DRAW_HISTOGRAM
#property indicator_color1clrGreen
#property indicator_style1STYLE_SOLID
#property indicator_width11
//--- plot junzhi
#property indicator_label2"junzhi"
#property indicator_type2 DRAW_LINE
#property indicator_color2clrRed
#property indicator_style2STYLE_SOLID
#property indicator_width21
//--- input parameters
input int zhouqi=24;
//--- indicator buffers
double chuzhiBuffer[];
double junzhiBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//--- indicator buffers mapping
SetIndexBuffer(0,chuzhiBuffer);
SetIndexBuffer(1,junzhiBuffer);
//---
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[])
{
//---
int i,limit;
limit=rates_total-prev_calculated;
if(prev_calculated>0)
limit++;
if(prev_calculated==0)
{
for(i=0;i<limit-3;i++)
{
chuzhiBuffer=(close+close+close)/3-close;
}
}
else
{
for(i=0;i<limit;i++)
{
chuzhiBuffer=(close+close+close)/3-close;
}
}
for(i=0;i<limit;i++)
{
junzhiBuffer=iMAOnArray(chuzhiBuffer, Bars, zhouqi, 0, MODE_SMA, i);
}
//--- return value of prev_calculated for next call
return(rates_total);
}
//+------------------------------------------------------------------+ 给金币. 值得研究
页:
[1]