
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Please I have this program that runs and draws the 3 lines well. But the other program below does not draw the 2 lines. The idea was to use the array as a variable inside start function. I have placed also as a static array and the same, does not draw the line. The idea is to use arrays declared inside the start function not as global arrays. What is wrong?
Any help please at intechsrl@gmail.com
#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_color3 Peru
double P1[];
double P2[];
double P3[];
int init()
{
SetIndexBuffer(0,P1);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
SetIndexBuffer(1,P2);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);
SetIndexBuffer(2,P3);
SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,3);
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int limit;
int counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
limit=Bars-2-counted_bars;
for(int i=limit; i>=0;i--)
P1[i]=iMA(NULL,0,3,0,MODE_SMA,PRICE_CLOSE,i);
for(i=limit; i>=0;i--)
P2[i]=iMAOnArray(P1,0,3,0,MODE_SMA,i);
for(i=limit; i>=0;i--)
P3[i]=iMAOnArray(P2,0,3,0,MODE_SMA,i);
return(0);
}
this is the same program but does not draw the 2 lines as expected
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 White
#property indicator_color2 Peru
double P1[];
double P3[];
int init()
{
SetIndexBuffer(0,P1);
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,3);
SetIndexBuffer(1,P3);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,3);
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int limit;
double P2[15000];
int counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
limit=Bars-2-counted_bars;
for(int i=limit; i>=0;i--)
P1[i]=iMA(NULL,0,3,0,MODE_SMA,PRICE_CLOSE,i);
for(i=limit; i>=0;i--)
P2[i]=iMAOnArray(P1,0,3,0,MODE_SMA,i);
for(i=limit; i>=0;i--)
P3[i]=iMAOnArray(P2,0,3,0,MODE_SMA,i);
return(0);
}