I have programming experience with other platforms but this is my first attempt at metatrader and a C++ based language and I need some help. I wanted to start with a simple indicator to plot highest high and lowest low with varying timeframes on one chart. The code compiles but nothing plotted when added to a chart:
Inserted Code
#property copyright "Internets" #property link "" #property indicator_chart_window #property indicator_buffers 4 //----input parameters extern int timeframe1 = 15; extern int timeframe2 = 240; //--- indicator Buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicator buffers mapping SetIndexBuffer(0,ExtMapBuffer1); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(1,ExtMapBuffer2); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(2,ExtMapBuffer3); SetIndexStyle(2,DRAW_LINE); SetIndexBuffer(3,ExtMapBuffer4); SetIndexStyle(3,DRAW_LINE); /*---- Create Rectangle indicators ObjectCreate(sObjName, OBJ_RECTANGLE, 0, 0, 0, 0, 0); ObjectSet(sObjName, OBJPROP_STYLE, STYLE_SOLID); ObjectSet(sObjName, OBJPROP_COLOR, cObjColor); ObjectSet(sObjName, OBJPROP_BACK, bProp_Back); */ return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int limit; int pos = 0; double highT1; double lowT1; double highT2; double lowT2; //---- Script to Count Number of Bars on Chart if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- Main Code for(int i =0;i<=timeframe1;i++) { if(High[i]>highT1) highT1 = High[i]; if(Low[i]<lowT1) lowT1 = Low[i]; } for(int j =1;j<=timeframe2;j++) { if(High[j]>highT2) highT2 = High[j]; if(Low[j]<lowT2) lowT2 = Low[j]; } for(pos = Bars; pos >= 0 ;pos--) { ExtMapBuffer1[pos] = highT1; ExtMapBuffer2[pos] = lowT1; ExtMapBuffer3[pos] = highT2; ExtMapBuffer4[pos] = lowT2; } return(0); } //+------------------------------------------------------------------+