HELP PLEASE! custome indicator code compiled well but doesn't load up on charts
Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!

Thank you.
Sergey Golubev:
ok sure.//+------------------------------------------------------------------+ //| king.Naser.mq5 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2017, MetaQuotes Software Corp." #property link "https://www.mql5.com" //---- indicator settings #property indicator_chart_window #property indicator_buffers 4 #property indicator_plots 4 #property indicator_type1 DRAW_LINE #property indicator_type2 DRAW_LINE #property indicator_type3 DRAW_LINE #property indicator_type4 DRAW_LINE #property indicator_color1 Blue #property indicator_color2 Red #property indicator_color3 Green #property indicator_color4 White #property indicator_width1 1 #property indicator_width2 1 #property indicator_width3 1 #property indicator_width4 1 #property indicator_label1 "CURRENCY1" #property indicator_label2 "CURRENCY2" #property indicator_label3 "CURRENCY3" #property indicator_label4 "Moving Average" //---- input parameters input int PERIOD = 400; input string CURRENCY_1="GBPUSD"; input string CURRENCY_2="USDJPY"; input string CURRENCY_3="GBPJPY"; //for inverting the charts set 0-----------// int dir_CURRENCY1 = 1; // int dir_CURRENCY2 = 1; // int dir_CURRENCY3 = 1; // // //-----------------------------------------// //---- indicator buffers double ExtMapBuffer1[]; double ExtMapBuffer2[]; double ExtMapBuffer3[]; double ExtMapBuffer4[]; double CURRENCY1[], CURRENCY2[], CURRENCY3[], c4[]; //------------------- int ia, ib, ic, id, ie = 0; int cnt1, cnt2, temp0, temp1 = 0; double centre_CURRENCY1, centre_CURRENCY2, centre_CURRENCY3; double centre_curent; //--- bars minimum for calculation int ExtBarsMinimum; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ void OnInit() { //---- indicator buffers mapping SetIndexBuffer(0,ExtMapBuffer1,INDICATOR_CALCULATIONS); SetIndexBuffer(1,ExtMapBuffer2,INDICATOR_CALCULATIONS); SetIndexBuffer(2,ExtMapBuffer3,INDICATOR_CALCULATIONS); SetIndexBuffer(3,ExtMapBuffer4,INDICATOR_CALCULATIONS); //--- set accuracy IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //---- sets first bar from what index will be drawn PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,PERIOD-1); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,PERIOD-1); PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,PERIOD-1); PlotIndexSetInteger(3,PLOT_DRAW_BEGIN,PERIOD-1); //---- name for DataWindow PlotIndexSetString(0,PLOT_LABEL,CURRENCY_1); PlotIndexSetString(1,PLOT_LABEL,CURRENCY_2); PlotIndexSetString(2,PLOT_LABEL,CURRENCY_3); PlotIndexSetString(3,PLOT_LABEL,"MOVING AVERAGE"); //--- get handles //--- initialization done } //+------------------------------------------------------------------+ //| OnCalculate function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { //--- check for rates total if(rates_total<PERIOD) return(0); // not enough bars for calculation //--- we can copy not all data int to_copy; if(prev_calculated>rates_total || prev_calculated<0) to_copy=rates_total; else { to_copy=rates_total-prev_calculated; if(prev_calculated>0) to_copy++; } //---- get buffers if(IsStopped()) return(0); //Checking for stop flag if(CopyBuffer(0,0,0,to_copy,ExtMapBuffer1)<=0) { Print("getting ExtMapBuffer1 is failed! Error",GetLastError()); return(0); } if(IsStopped()) return(0); //Checking for stop flag if(CopyBuffer(0,0,0,to_copy,ExtMapBuffer2)<=0) { Print("getting ExtMapBuffer2 is failed! Error",GetLastError()); return(0); } if(IsStopped()) return(0); //Checking for stop flag if(CopyBuffer(0,0,0,to_copy,ExtMapBuffer3)<=0) { Print("getting ExtMapBuffer3 is failed! Error",GetLastError()); return(0); } if(IsStopped()) return(0); //Checking for stop flag if(CopyBuffer(0,0,0,to_copy,ExtMapBuffer4)<=0) { Print("getting ExtMapBuffer4 is failed! Error",GetLastError()); return(0); } int count; ArraySetAsSeries(close,true); CopyClose(CURRENCY_1,_Period,0,count,CURRENCY1); CopyClose(CURRENCY_2,_Period,0,count,CURRENCY2); CopyClose(CURRENCY_3,_Period,0,count,CURRENCY3); CopyClose(_Symbol,_Period,0,count,c4); int Bars=Bars(_Symbol,_Period); temp0 = Bars - 1; if(ArraySize(CURRENCY1) < temp0 + 1) { temp0 = ArraySize(CURRENCY1) - 1; Comment(CURRENCY_1 + _Period + " " + ArraySize(CURRENCY1)); } if(ArraySize(CURRENCY2) < temp0 + 1) { temp0 = ArraySize(CURRENCY2) - 1; Comment(CURRENCY_2 + _Period + " " + ArraySize(CURRENCY2)); } if(ArraySize(CURRENCY3) < temp0 + 1 ) { temp0 = ArraySize(CURRENCY3) - 1; Comment(CURRENCY_3 + _Period + " " + ArraySize(CURRENCY3)); } //---- if(PERIOD >= temp0) { Comment("error "); return(0); } //---------------- if(temp0 - PERIOD < Bars - PERIOD) temp1 = temp0 - PERIOD; else temp1 = Bars - PERIOD; //---- for(ia = temp1; ia >= 0; ia--) { //----------- centre_CURRENCY1 = 0; centre_CURRENCY2 = 0; centre_CURRENCY3 = 0; centre_curent = 0; //---- for(ic = PERIOD - 1; ic >= 0; ic--) { centre_CURRENCY1 = centre_CURRENCY1 + CURRENCY1[ia+ic]; centre_CURRENCY2 = centre_CURRENCY2 + CURRENCY2[ia+ic]; centre_CURRENCY3 = centre_CURRENCY3 + CURRENCY3[ia+ic]; centre_curent = centre_curent + c4[ia+ic]; } centre_CURRENCY1 = centre_CURRENCY1 / PERIOD; centre_CURRENCY2 = centre_CURRENCY2 / PERIOD; centre_CURRENCY3 = centre_CURRENCY3 / PERIOD; centre_curent = centre_curent / PERIOD; //----------- ExtMapBuffer1[ia] = (dir_CURRENCY1*CURRENCY1[ia] + (1 - dir_CURRENCY1) / CURRENCY1[ia])*centre_curent / (dir_CURRENCY1*centre_CURRENCY1 + (1 - dir_CURRENCY1) / centre_CURRENCY1); ExtMapBuffer2[ia] = (dir_CURRENCY2*CURRENCY2[ia] + (1 - dir_CURRENCY2) / CURRENCY2[ia])*centre_curent / (dir_CURRENCY2*centre_CURRENCY2 + (1 - dir_CURRENCY2) / centre_CURRENCY2); ExtMapBuffer3[ia] = (dir_CURRENCY3*CURRENCY3[ia] + (1 - dir_CURRENCY3) / CURRENCY3[ia])*centre_curent / (dir_CURRENCY3*centre_CURRENCY3 + (1 - dir_CURRENCY3) / centre_CURRENCY3); ExtMapBuffer4[ia] = (ExtMapBuffer1[ia]+ExtMapBuffer2[ia]+ExtMapBuffer3[ia])/3; } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+
hello everybody
I have written an indicator code but when I drag it on charts nothing would be shown on chart!
Since I am a novice coder I can't find the problem, I have reviewed it more than 50 times :((((
It's an indicator to show different markets in one chart simultaneously in points not their real price.
I am really appreciated if someone can help me solve this, here is the code