High Programmers,
I was unable to show all indicator buffer lines on the chart. Only the first one is shown. Please note that the lines represent different time periods and shifts.
it will be appreciated if someone fixes the indicator and show me where I got it wrong.
Regards,
I was unable to show all indicator buffer lines on the chart. Only the first one is shown. Please note that the lines represent different time periods and shifts.
it will be appreciated if someone fixes the indicator and show me where I got it wrong.
Inserted Code
//+------------------------------------------------------------------+ //| Trend.mq4 | //+------------------------------------------------------------------+ #property copyright "Copyright © 2004, MetaQuotes Software Corp." #property link "[url]http://www.metaquotes.net/[/url]" //---- indicator settings #property indicator_chart_window #property indicator_buffers 4 //---------------------- #property indicator_color1 Green #property indicator_color2 Red #property indicator_color3 Blue #property indicator_color4 Orange //---- indicators parameters extern int LWMA_Fast=7; extern int MACD_Fast=12; extern int MACD_Slow=26; extern int MACD_Signal=9; //---- indicator buffers double LWMA_Buffer_1[]; double LWMA_Buffer_2[]; double MACD_Buffer_0[]; double MACD_Buffer_1[]; //---- //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(4); //---- drawing settings SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(3,DRAW_LINE,STYLE_SOLID,2); //---- indicator buffers mapping SetIndexBuffer(0,LWMA_Buffer_1); SetIndexBuffer(1,LWMA_Buffer_2); SetIndexBuffer(2,MACD_Buffer_0); SetIndexBuffer(3,MACD_Buffer_1); //---- name/label for indicators IndicatorShortName("Trend"); SetIndexLabel(0,"LWMA_Buffer_1"); SetIndexLabel(1,"LWMA_Buffer_2"); SetIndexLabel(2,"MACD_Buffer_0"); SetIndexLabel(3,"MACD_Buffer_1"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator start function | //+------------------------------------------------------------------+ int start() { int limit; int counted_bars=IndicatorCounted(); //---- last counted bar will be recounted if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- LWMA[1] loop for(int i=0; i<limit; i++) LWMA_Buffer_1[i+1]=iMA(Symbol(),PERIOD_H4,LWMA_Fast,0,MODE_LWMA,PRICE_TYPICAL,i+1); //---- LWMA[2] loop for(i=0; i<limit; i++) LWMA_Buffer_1[i+2]=iMA(Symbol(),PERIOD_H4,LWMA_Fast,0,MODE_LWMA,PRICE_TYPICAL,i+2); //---- MACD[0] loop for(i=0; i<limit; i++) MACD_Buffer_0[i]=iMACD(NULL,PERIOD_D1,MACD_Fast,MACD_Slow,MACD_Signal,PRICE_WEIGHTED,MODE_MAIN,i); //---- MACD[1] loop for(i=0; i<limit; i++) MACD_Buffer_1[i+1]=iMACD(NULL,PERIOD_D1,MACD_Fast,MACD_Slow,MACD_Signal,PRICE_WEIGHTED,MODE_MAIN,i+1); //---- done return(0); } //+--------------------------------
Regards,
Free Programmer for Profitable Strategies