尊敬的Rosh先生,您好!求助关于画图问题。

 

尊敬的Rosh 先生:

您好!以下代码是由BANDS指标修改而来,但是运行的时候,出现问题:不能正确地画图。

请您帮忙指出问题出现在哪里。我是在一分钟图表下运行,其中一条线的数据用到了其它图表的

不同货币对和不同周期下的数据,这种情况下是否要用到iBarShift()做坐标转换? 如果是,该如何修改?

因为本人对编程了解很少,还恳请Rosh 先生帮忙!

谢谢!

//+------------------------------------------------------------------+
//| bands.mq4 |
//| Copyright ?2005, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2005, MetaQuotes Software Corp."
#property link "https://www.metaquotes.net//"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 OrangeRed
extern int BandsPeriod=20;
extern int BandsShift=0;
extern double BandsDeviations=2.0;
double ind_buffer1[];
double ind_buffer2[];

int init()
{
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ind_buffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ind_buffer2);
SetIndexDrawBegin(0,BandsPeriod+BandsShift);
SetIndexDrawBegin(1,BandsPeriod+BandsShift);
SetIndexLabel(0,"1MIN");
SetIndexLabel(1,"5MIN");
IndicatorShortName("bands");

return(0);
}

int start()
{

int i,k,counted_bars=IndicatorCounted();
double sum,oldval,newres;
double summ,oldvall,newress;
double M1,M5,C1,A1,C5,A5;

i=Bars-BandsPeriod+1;
if(counted_bars>BandsPeriod-1) i=Bars-counted_bars-1;
while(i>=0)
{
sum=0.0;

summ=0.0;

k=i+BandsPeriod-1;
oldval=iMA("EURJPY",PERIOD_M1,20,0,MODE_SMA,PRICE_CLOSE,i);

oldvall=iMA("EURJPY",PERIOD_M5,20,0,MODE_SMA,PRICE_CLOSE,i);


while(k>=i)
{
C1=iClose("EURJPY",PERIOD_M1,k)-oldval;
A1+=C1*C1;

C5=iClose("EURJPY",PERIOD_M5,k)-oldvall;
A5+=C5*C5;

k--;
}

M1=BandsDeviations*MathSqrt(A1/BandsPeriod);

M5=BandsDeviations*MathSqrt(A5/BandsPeriod);

ind_buffer1[i]=oldval+M1;

ind_buffer2[i]=oldvall-M5;



i--;
}

return(0);
}