Thanks, 240z for your reply... I have done what you suggested many times and many variations. and I still get just the one Red sin wave. I pasted the code with my additions for the second buffer highlighted in green, below.
If you or anyone else can detect where I am coding wrong please let me know what I am doing wrong. Thanks
I think my problem is somewhere below the ... int start() line. Otherwise, I have no clue.
//+------------------------------------------------------------------+
//| Accelerator.mq4 |
//| Copyright ?2005, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2 // org 1
#property indicator_color1 Red //
#property indicator_color2 Orange //
//---- indicator buffers
double ExtBuffer1[];
double ExtBuffer2[];
double Dgr[];
double Dgr2[];
extern datetime StartTime=D'1999.11.10 00:00';
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE); // 0
SetIndexStyle(1,DRAW_LINE); // 0
SetLevelValue(0,0); //
//----indicator buffers mapping //
SetIndexBuffer(0,ExtBuffer1);
SetIndexBuffer(1,ExtBuffer2);
SetIndexShift(0,25); // B. added
SetIndexShift(1,25); // B. added
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator |
//+------------------------------------------------------------------+
int start()
{
int Shift;
int i;
Shift=iBarShift(Symbol(),PERIOD_D1,StartTime); // Only run on PERIOD_D1
ArrayResize(Dgr,Shift+1); // ArrayResize(Dgr,Shift+1); ?????????????????
ArrayResize(Dgr2,Shift+1);
MyCalc(Shift,1); // ??? 1
for(i=Shift; i>=0; i--)
ExtBuffer1[i]=Dgr[i];
ExtBuffer2[i]=Dgr2[i];
return(0);
}
//+----------------------------------------------------------------+
void MyCalc(int Shift,int Yhigh)
{
int i;
for(i=Shift;i>=0;i--) // should be >
{
Dgr[i]=i*2.5;
Dgr2[i]=i*2.5;
// ..... B. added code below
double val=i*2.5; // 2.5
double val2=i*2.5; // 2.5
Dgr[i]=MathSin(3.14159*val/149)+Yhigh; // 149
Dgr2[i]=MathSin(3.14159*val2/49)+Yhigh; // 49
// ..... B. added above code
}
}
If you or anyone else can detect where I am coding wrong please let me know what I am doing wrong. Thanks
I think my problem is somewhere below the ... int start() line. Otherwise, I have no clue.
//+------------------------------------------------------------------+
//| Accelerator.mq4 |
//| Copyright ?2005, MetaQuotes Software Corp. |
//| https://www.metaquotes.net// |
//+------------------------------------------------------------------+
//---- indicator settings
#property indicator_separate_window
#property indicator_buffers 2 // org 1
#property indicator_color1 Red //
#property indicator_color2 Orange //
//---- indicator buffers
double ExtBuffer1[];
double ExtBuffer2[];
double Dgr[];
double Dgr2[];
extern datetime StartTime=D'1999.11.10 00:00';
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
SetIndexStyle(0,DRAW_LINE); // 0
SetIndexStyle(1,DRAW_LINE); // 0
SetLevelValue(0,0); //
//----indicator buffers mapping //
SetIndexBuffer(0,ExtBuffer1);
SetIndexBuffer(1,ExtBuffer2);
SetIndexShift(0,25); // B. added
SetIndexShift(1,25); // B. added
//---- initialization done
return(0);
}
//+------------------------------------------------------------------+
//| Accelerator/Decelerator Oscillator |
//+------------------------------------------------------------------+
int start()
{
int Shift;
int i;
Shift=iBarShift(Symbol(),PERIOD_D1,StartTime); // Only run on PERIOD_D1
ArrayResize(Dgr,Shift+1); // ArrayResize(Dgr,Shift+1); ?????????????????
ArrayResize(Dgr2,Shift+1);
MyCalc(Shift,1); // ??? 1
for(i=Shift; i>=0; i--)
ExtBuffer1[i]=Dgr[i];
ExtBuffer2[i]=Dgr2[i];
return(0);
}
//+----------------------------------------------------------------+
void MyCalc(int Shift,int Yhigh)
{
int i;
for(i=Shift;i>=0;i--) // should be >
{
Dgr[i]=i*2.5;
Dgr2[i]=i*2.5;
// ..... B. added code below
double val=i*2.5; // 2.5
double val2=i*2.5; // 2.5
Dgr[i]=MathSin(3.14159*val/149)+Yhigh; // 149
Dgr2[i]=MathSin(3.14159*val2/49)+Yhigh; // 49
// ..... B. added above code
}
}