Problem with ArraySort() indicator Heatmap for MQL5

 
I have tried modifying the Heatmap_Gradient_Scale.mq5 flag to be able to sort all symbols in the market watch window but I am not able. I have tried a 2d array more arraysort (). In mql4 I don't get any problem.

ERROR - "displaylist" - parameter conversion not allowed .    Any ideas where to start? Thank you.
                #include <mql4compat.mqh>
//--- INPUTS
input bool   sort                               = true; // Sort on value
input int    sortmode                           = 1; // 0 = ASCEND 1 - DESCEND

//--- GLOBALS
string         marketWatchSymbolsList[];
double         percentChange[];
color          colorArray[];
//---
int            symbolsTotal=0;
//---
MqlRates       DailyBar[];
double         displaylist[i][3];


      displaylist[i][0] = percentChange[i];      // % the change
      displaylist[i][1] = heatmapColor;         // colour the boxes
      displaylist[i][2] = i;                   // names the symbols

   }  
      if (sort == true) {
      if (sortmode == 0)
      ArraySortMQL4(displaylist,WHOLE_ARRAY,0,MODE_ASCEND);
      else
      ArraySortMQL4(displaylist,WHOLE_ARRAY,0,MODE_DESCEND);
   } 


 

Hi,

this Was the code i made for sorting the Symbols in a table the compiled version was commented some where in the forum.

One can edit the font size table rows and etc...

(Please clean the code. some lines are not used like the ENUM... but is was still there any way!!! or change the Yes NO question to ENUM true/false )

#property version   "1.00"
#property indicator_chart_window
#property indicator_plots   0
//--- ENUMS
enum ENUM_INDICATOR_TYPE   {HEATMAP};
ENUM_INDICATOR_TYPE  indicatorType        =  HEATMAP;
//--- INPUTS
input int      TableRows   =   16;     //Table Rows
input int      NoF         =   30;     //Number of Candels
input int      fontsize    =   9;      //Font Size
input string  posym="YES" ;            //Scan Positive Values (YES or NO)
input string nesym="YES" ;            //Scan Negative Values (YES or NO)
string         marketWatchSymbolsList[];
double         percentChange[];
color          colorArray[];
//---
int            symbolsTotal=0;
//---
MqlRates       DailyBar[];
//+------------------------------------------------------------------+
//| Indicator initialization function                                |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   if(SymbolsTotal(true)<5)
     {
      Alert("The minimum number of symbols must be 5 (five).");
      return(INIT_PARAMETERS_INCORRECT);
     }
//---
   EventSetTimer(1);
//--- 
   ArraySetAsSeries(DailyBar,true);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Indicator deinitialization function                              |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//--- Delete only what is drawn by your code
   deleteScale(symbolsTotal);
   ChartRedraw();
  }
//+------------------------------------------------------------------+
//| Indicator iteration 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 &tickVolume[],
                const long &volume[],
                const int &spread[])
  {
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| Timer function                                                   |
//+------------------------------------------------------------------+
void OnTimer()
  {
   int currentSymbolsTotal=SymbolsTotal(true);
//--- If we add or remove a symbol to the market watch
   if(symbolsTotal!=currentSymbolsTotal)
     {
      //--- resize arrays 
      ArrayResize(marketWatchSymbolsList,currentSymbolsTotal);
      ArrayResize(percentChange,currentSymbolsTotal);
      ArrayResize(colorArray,currentSymbolsTotal);
      //--- update arrays of symbol's name
      for(int i=0;i<currentSymbolsTotal;i++) marketWatchSymbolsList[i]=SymbolName(i,true);
      //--- remove panel in excess
      deleteScale(symbolsTotal,currentSymbolsTotal);
      //---
      symbolsTotal=currentSymbolsTotal;
     }
//--- call right drawing function
   switch(indicatorType)
     {
      case HEATMAP   : Heatmap(); break;
     }
   ChartRedraw();
  }
//+------------------------------------------------------------------+
//| HEATMAP                                                          |
//+------------------------------------------------------------------+
void Heatmap()
  {
//--- locals
   double scaleMax,scaleMin,scaleEdge;
//---
   int    arrayMax,arrayMin;
//--- Color 1 parameters
   int r_1 = 0;
   int g_1 = 255;
   int b_1 = 0;
//--- Color 2 parameters
   int r_2 = 255;
   int g_2 = 255;
   int b_2 = 255;
//--- Color 3 parameters
   int r_3 = 255;
   int g_3 = 0;
   int b_3 = 0;
   int midValue=(symbolsTotal%2==0 ? symbolsTotal/2 :(symbolsTotal-1)/2)-1;
//--- Build an array of colors and calculate percentage price's change
   for(int i=0;i<symbolsTotal;i++)
     {
      //--- Local variables
      int r_value = r_2;
      int g_value = g_2;
      int b_value = b_2;
      //--- Calculates the percent change of each symbol
      if(CopyRates(marketWatchSymbolsList[i],PERIOD_D1,0,NoF,DailyBar)==NoF)
        {
         percentChange[i]=((DailyBar[0].close/DailyBar[NoF-1].close)-1)*100;
         if(i<=midValue) // Positive values
           {
            //--- Positive interpolation function
            r_value = r_1-i*(r_1-r_2)/midValue;
            g_value = g_1-i*(g_1-g_2)/midValue;
            b_value = b_1-i*(b_1-b_2)/midValue;
           }
         else
           {
            //--- Negative interpolation function
            r_value = r_2-(i-midValue-1)*(r_2-r_3)/midValue;
            g_value = g_2-(i-midValue-1)*(g_2-g_3)/midValue;
            b_value = b_2-(i-midValue-1)*(b_2-b_3)/midValue;
           }
        }
      //--- Sets all possible colors to the array colorArray[]
      string rgbColor=IntegerToString(r_value)+","+IntegerToString(g_value)+","+IntegerToString(b_value);
      colorArray[i]=StringToColor(rgbColor);
     }
//--- Determine maximum/minimum and the scale value
   arrayMax=ArrayMaximum(percentChange); arrayMin=ArrayMinimum(percentChange);
   if(arrayMax==-1 || arrayMin==-1) return;

//--- Determine the scale
   scaleEdge=MathMax(MathAbs(percentChange[arrayMax]),MathAbs(percentChange[arrayMin]));
//---
   scaleMax=scaleEdge; scaleMin=-scaleEdge;
   midValue=(symbolsTotal%2==0 ? symbolsTotal/2 :(symbolsTotal-1)/2);
//--- Sets colors to the heatmap
int jj=0;
int jp=0;
   for(int i=0;i<symbolsTotal;i++)
     {
      //--- Local variable
      int heatmapColor=0;

      //--- Sets the color position (gradientColor) inside the colorArray
      if(percentChange[i]>0)
        {
         //--- color index between 0 and (symbolsTotal/2)-1
         heatmapColor=(int)MathFloor((1-percentChange[i]/scaleMax)*midValue);
        }
      else if(percentChange[i]<0)
        {
         //--- color index between symbolsTotal/2 and symbolsTotal-1
        heatmapColor=(int)MathCeil((percentChange[i]/scaleMin)*midValue)+midValue-1;
        }
      else
        {
         heatmapColor=midValue; // Mid position
        }
      if(heatmapColor<0) Print("Array out of range, heatmapcolor=",heatmapColor);
      if(heatmapColor>=ArraySize(colorArray)) Print("Array out of range, heatmapcolor=",heatmapColor," colorArray size=",ArraySize(colorArray));
      //--- Texts and boxes
              int xpos=10;
              xpos=xpos+50*jp;
      if(percentChange[i]>=0&&posym=="YES")
        {
              SetPanel("Panel "+IntegerToString(i),0,xpos,32+(jj-jp*TableRows)*32,50,30,colorArray[heatmapColor],clrWhite,1);
              //SetPanel(string name,int sub_window,x,y,width,height,bg_color,border_clr,int border_width)
               SetText("Text "+IntegerToString(i),marketWatchSymbolsList[i],xpos+3,33+(jj-jp*TableRows)*32,clrBlack,fontsize);
              //SetText(name, text,int x,int y,color colour,int fontsize=12)
              SetText("Variation "+IntegerToString(i),"+"+DoubleToString(percentChange[i],1)+"%",xpos+7,46+(jj-jp*TableRows)*32,clrBlack,fontsize);
        }
      else if ((percentChange[i]<0&&nesym=="YES"))
        {
              SetPanel("Panel "+IntegerToString(i),0,xpos,32+(jj-jp*TableRows)*32,50,30,colorArray[heatmapColor],clrWhite,1);
              SetText("Text "+IntegerToString(i),marketWatchSymbolsList[i],xpos+3,33+(jj-jp*TableRows)*32,clrBlack,fontsize+2);
              SetText("Variation "+IntegerToString(i),DoubleToString(percentChange[i],1)+"%",xpos+7,46+(jj-jp*TableRows)*32,clrBlack,fontsize+2);
        }  
              jj=jj+1;
              jp = (int)MathFloor(jj/TableRows);   
     }
//---
  }
//+------------------------------------------------------------------+
//| Remove unneeded objects from main chart                          |
//+------------------------------------------------------------------+
void deleteScale(int from,int to=1)
  {
//---   
   from--;to--;
   for(int i=from;i>=to;i--)
     {
      ObjectDelete(0,"Panel "+IntegerToString(i));
      ObjectDelete(0,"Text "+IntegerToString(i));
      ObjectDelete(0,"Variation "+IntegerToString(i));
     }
  }
//+------------------------------------------------------------------+
//| Draw data about a symbol in a panel                              |
//+------------------------------------------------------------------+
void SetText(string name,string text,int x,int y,color colour,int fontsize2=12)
  {
   if(ObjectCreate(0,name,OBJ_LABEL,0,0,0))
     {
      ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
      ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
      ObjectSetInteger(0,name,OBJPROP_COLOR,colour);
      ObjectSetInteger(0,name,OBJPROP_FONTSIZE,fontsize);
      ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
     }
   ObjectSetString(0,name,OBJPROP_TEXT,text);
  }
//+------------------------------------------------------------------+
//| Draw a panel with given color for a symbol                       |
//+------------------------------------------------------------------+
void SetPanel(string name,int sub_window,int x,int y,int width,int height,color bg_color,color border_clr,int border_width)
  {
   if(ObjectCreate(0,name,OBJ_RECTANGLE_LABEL,sub_window,0,0))
     {
      ObjectSetInteger(0,name,OBJPROP_XDISTANCE,x);
      ObjectSetInteger(0,name,OBJPROP_YDISTANCE,y);
      ObjectSetInteger(0,name,OBJPROP_XSIZE,width);
      ObjectSetInteger(0,name,OBJPROP_YSIZE,height);
      ObjectSetInteger(0,name,OBJPROP_COLOR,border_clr);
      ObjectSetInteger(0,name,OBJPROP_BORDER_TYPE,BORDER_FLAT);
      ObjectSetInteger(0,name,OBJPROP_WIDTH,border_width);
      ObjectSetInteger(0,name,OBJPROP_CORNER,CORNER_LEFT_UPPER);
      ObjectSetInteger(0,name,OBJPROP_STYLE,STYLE_SOLID);
      ObjectSetInteger(0,name,OBJPROP_BACK,false);
      ObjectSetInteger(0,name,OBJPROP_SELECTABLE,0);
      ObjectSetInteger(0,name,OBJPROP_SELECTED,0);
      ObjectSetInteger(0,name,OBJPROP_HIDDEN,true);
      ObjectSetInteger(0,name,OBJPROP_ZORDER,0);
     }
   ObjectSetInteger(0,name,OBJPROP_BGCOLOR,bg_color);
  }
//+------------------------------------------------------------------+
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Properties
Documentation on MQL5: Constants, Enumerations and Structures / Objects Constants / Object Properties
  • www.mql5.com
All objects used in technical analysis are bound to the time and price coordinates: trendline, channels, Fibonacci tools, etc. But there is a number of auxiliary objects intended to improve the user interface that are bound to the always visible part of a chart (main chart windows or indicator subwindows): – defines the chart corner relative to...
 
hhr_rahimi: Please clean the code.

You haven't stated a problem, you stated a want. You have only four choices:

  1. Search for it. Do you expect us to do your research for you?

  2. Beg at:

  3. MT4: Learn to code it.
    MT5: Begin learning to code it.
    If you don't learn MQL4/5, there is no common language for us to communicate. If we tell you what you need, you can't code it. If we give you the code, you don't know how to integrate it into your code.

  4. or pay (Freelance) someone to code it.
              Hiring to write script - General - MQL5 programming forum 2019.08.21

We're not going to code it for you (although it could happen if you are lucky or the problem is interesting.) We are willing to help you when you post your attempt (using CODE button) and state the nature of your problem.
          No free help 2017.04.21

 
William Roeder:

You haven't stated a problem, you stated a want. You have only four choices:

this is a misunderstanding. :)

he asked a question which i had the solution,i pasted the solution for him.

  i've written this code about a year ago according to my own suggestions on the original page which are here https://www.mql5.com/en/code/6980

the code works fine, but it's not clean. and He should manage to clean it if he likes it for further use,

Regards

Heatmaps, color gradients and scales in MQL5
Heatmaps, color gradients and scales in MQL5
  • www.mql5.com
The purpose of this code is to demonstrate how easy it is to create color scales, color gradients and heatmaps with the MQL5 language and functions. In order to facilitate things, we will work with the RGB color model and the standard conversion function StringToColor. Other color conversion methods can be implemented in MQL5, however we have...
 
hhr_rahimi: this is a misunderstanding. :)

OK. Your statement "Please clean the code" sounded like a demand to us. "You'll have to clean up the code yourself" wouldn't have.

 
William Roeder:

"You'll have to clean up the code yourself" wouldn't have.

Yes.indeed you are right .
 
hhr_rahimi:

Hi,

this Was the code i made for sorting the Symbols in a table the compiled version was commented some where in the forum.

One can edit the font size table rows and etc...

(Please clean the code. some lines are not used like the ENUM... but is was still there any way!!! or change the Yes NO question to ENUM true/false )

wonderful job and thank you for this code