#property indicator_color1 Yellow #property indicator_color2 Red ...... SetIndexBuffer(0, OutPut1); SetIndexBuffer(1, OutPut2);
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
In the code shown below I intend to display two indicators but only one indicator gets displayed on the bar chart?
what am I doing wrong ?
Thanks,
Joe Miller
----------------------------
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Yellow //jm added
//---- BUFFERS
double OutPut1[];
double OutPut2[];
//---- INPUT(S)
extern int Periods = 1;
//+------------------------------------------------------------------+
//+ INIT |
//+------------------------------------------------------------------+
int init()
{
//---- ERROR TRAPS
if( Periods <= 0 ) { Alert("Invalid Periods"); return(-1); }
//---- INDICATOR STYLE
SetIndexShift(0,1); //jm start at 0?, shift 1
SetIndexBuffer(0, OutPut1);
SetIndexBuffer(0, OutPut2);
SetIndexStyle( 0, DRAW_LINE, STYLE_SOLID, 1, Red);
SetIndexDrawBegin(0, Periods );
//----
return(0);
}
//+------------------------------------------------------------------+
//+ DEINIT |
//+------------------------------------------------------------------+
int deinit() { return(0); }
//+------------------------------------------------------------------+
//+ START |
//+------------------------------------------------------------------+
int start()
{
//---- Find MaxRecords
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) { counted_bars--; }
int MaxRecords = Bars-counted_bars;
Periods=1;
for( int i = 0; i < MaxRecords ; i++ )
{
double sum1dayma = 0.0;
for( int k = 0; k < Periods; k++ )
{
sum1dayma += (High[i+k]+Low[i+k])/2;
}
OutPut1[i] = sum1dayma/Periods;
}
Periods=3;
for( i = 0; i < MaxRecords ; i++ )
{
double sum3dayma = 0.0;
for( k = 0; k < Periods; k++ )
{
sum3dayma += (High[i+k]+Low[i+k])/2;
}
OutPut2[i] = sum3dayma/Periods;
}