Questions from Beginners MQL5 MT5 MetaTrader 5 - page 689

 
Roma Ivanov:
the formula is from here - https://www.mql5.com/ru/articles/1492
in the article at the link -- the operation ^ is a power increase
 
Roma Ivanov:
The formula is taken from here - https://www.mql5.com/ru/articles/1492

I haven't read it. But judging by the formula and the graphs in the article (Excel), it's a power increase.

I could be wrong.

 

Good time! Wondering how to translate a 2D array into *.csv format, found a suitable example, but it's for mt4, needed for 5.

//+------------------------------------------------------------------+
//|                                                  generateCsv.mq4 |
//|         Copyright © 2006, Antonio Banderass. All rights reserved |
//|                                               banderassa@ukr.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Antonio Banderass. All rights reserved"
#property link      "banderassa@ukr.net"
#property library
#define ARRAY_SIZE_X 16
#define ARRAY_SIZE_Y 16
//+------------------------------------------------------------------+
//| PrepareString                                                    |
//+------------------------------------------------------------------+
string PrepareString(string s)
  {
   bool exit = false;
   int index = 0;
   string str = s;
//----
   while(!exit)
     {
       index = StringFind(str, ".", index);
       if(index > -1)
           str = StringSetCharacter(str, index, ',');
       else
           exit = true;
     }
   return(str);
  }
//+------------------------------------------------------------------+
//| GenerateCsv                                                      |
//+------------------------------------------------------------------+
int GenerateCsv(string fileName, int arraySizeX, int arraySizeY,
                double arrayIndexX[], double arrayIndexY[], double arrayZ[][]) // Ругается говорит - arrays are passed by reference only пробовал добавить &_array.. но запинается на двумерном

  {
   int handle = FileOpen(fileName, FILE_CSV|FILE_WRITE, ' '), x, y;
   string str;
   if(handle < 1)
     {
       Print("Error:", GetLastError());
       return(handle);
     }
   else
     {
       str = ";";
       for(x = 0; x < arraySizeX; x++)
         {
           str = str + arrayIndexX[x];
           str = str + ";";        
         }
       FileWrite(handle, PrepareString(str));
       for(y = 0; y < arraySizeY; y++)
         {
           str = "";  
           str = str + arrayIndexY[y] + ";";
           for(x = 0; x < arraySizeX; x++)
             {
               str = str + arrayZ[x,y];
               str = str + ";";        
             }
           FileWrite(handle, PrepareString(str));
         }
     }
   FileClose(handle);  
   return(handle);
  }
//+------------------------------------------------------------------+

https://www.mql5.com/ru/articles/1443

Трёхмерные графики - профессиональный инструмент анализа рынка
Трёхмерные графики - профессиональный инструмент анализа рынка
  • 2006.12.06
  • Antoniuk Oleg
  • www.mql5.com
В это статье мы напишем простую библиотеку для создания трехмерных графиков и последующего их проcмотра в Microsoft Excel. Мы воспользуемся стандартными возможностями языка MQL 4 для подготовки и экспорта данных в файл формата *.csv.
Files:
 
Top2n:

Good time! Wondering how to translate a 2D array into *.csv format, found a suitable example, but it's for mt4, needed for 5.

https://www.mql5.com/ru/articles/1443

Arrays can only be transferred by reference:

int GenerateCsv(string fileName, int arraySizeX, int arraySizeY,
                double & arrayIndexX[], double & arrayIndexY[], double & arrayZ[][])
 
Artyom Trishkin:

Arrays can only be transferred by reference:

int GenerateCsv(string fileName, int arraySizeX, int arraySizeY,
                double & arrayIndexX[], double & arrayIndexY[], double & arrayZ[][])
And yet it swears at&arrayZ[][] says -'[' - invalid index value

 
Top2n:
And yet it fails&arrayZ[][] says -'[' - invalid index value

And how many dimensions is arrayZ declared?
 
Artyom Trishkin:
And how many dimensions is arrayZ declared?

I declared &arrayZ[][3000], if I equate it to 16, then event handling function not foundat all

#define ARRAY_SIZE_X 16
#define ARRAY_SIZE_Y 16

int start()
  {
   int x, y;
   double arrayIndexX[ARRAY_SIZE_X];
   double arrayIndexY[ARRAY_SIZE_Y];
   double arrayZ[ARRAY_SIZE_X,ARRAY_SIZE_Y];
//----
   for(x = 0; x < ARRAY_SIZE_X; x++)
       arrayIndexX[x] = x / 10.0;      
//----
   for(y = 0; y < ARRAY_SIZE_Y; y++)
       arrayIndexY[y] = y / 10.0;
//----
   for(x = 0; x < ARRAY_SIZE_X; x++)
       for(y = 0; y < ARRAY_SIZE_Y; y++)
           arrayZ[x,y] = MathSin(arrayIndexX[x] + arrayIndexY[y]);
   GenerateCsv("test.csv", ARRAY_SIZE_X, ARRAY_SIZE_Y, arrayIndexX, arrayIndexY, arrayZ); // 'arrayZ' - parameter conversion not allowed
//----
   return(0);
  }

//+------------------------------------------------------------------+
//| PrepareString                                                    |
//+------------------------------------------------------------------+
string PrepareString(string s)
  {
   bool exit = false;
   int index = 0;
   string str = s;
//----
   while(!exit)
     {
       index = StringFind(str, ".", index);
       if(index > -1)
           str = StringSetCharacter(str, index, ',');
       else
           exit = true;
     }
   return(str);
  }
//+------------------------------------------------------------------+
//| GenerateCsv                                                      |
//+------------------------------------------------------------------+
int GenerateCsv(string fileName, int arraySizeX, int arraySizeY,
                double &arrayIndexX[], double &arrayIndexY[], double &arrayZ[][3000])
  {
   int handle = FileOpen(fileName, FILE_CSV|FILE_WRITE, ' '), x, y;
   string str;
   if(handle < 1)
     {
       Print("Error:", GetLastError());
       return(handle);
     }
   else
     {
       str = ";";
       for(x = 0; x < arraySizeX; x++)
         {
           str = str + arrayIndexX[x];
           str = str + ";";        
         }
       FileWrite(handle, PrepareString(str));
       for(y = 0; y < arraySizeY; y++)
         {
           str = "";  
           str = str + arrayIndexY[y] + ";";
           for(x = 0; x < arraySizeX; x++)
             {
               str = str + arrayZ[x,y];
               str = str + ";";        
             }
           FileWrite(handle, PrepareString(str));
         }
     }
   FileClose(handle);  
   return(handle);
  }
//+------------------------------------------------------------------+

 
Top2n:

Declared &arrayZ[][3000]

string PrepareString(string s);

int GenerateCsv(string fileName, int arraySizeX, int arraySizeY,

                double &arrayIndexX[], double &arrayIndexY[], 

                double &arrayZ[][3000]); 

int start()
  {
   int x, y;
   double arrayIndexX[ARRAY_SIZE_X];
   double arrayIndexY[ARRAY_SIZE_Y];
   double arrayZ[ARRAY_SIZE_X,ARRAY_SIZE_Y];
//----
   for(x = 0; x < ARRAY_SIZE_X; x++)
       arrayIndexX[x] = x / 10.0;      
//----
   for(y = 0; y < ARRAY_SIZE_Y; y++)
       arrayIndexY[y] = y / 10.0;
//----
   for(x = 0; x < ARRAY_SIZE_X; x++)
       for(y = 0; y < ARRAY_SIZE_Y; y++)
           arrayZ[x,y] = MathSin(arrayIndexX[x] + arrayIndexY[y]);
   GenerateCsv("test.csv", ARRAY_SIZE_X, ARRAY_SIZE_Y, arrayIndexX, arrayIndexY, arrayZ); // 'arrayZ' - parameter conversion not allowed
//----
   return(0);
  }


You've taken a ready-made one already. How is it done there? I can't look at it - I'm writing from my mobile.
 

How can I change the colour of a panel created using theCAppDialog class ?

   if(!CAppDialog::Create(chart,name,subwin,x1,y1,x2,y2))
      return(false);
 
Artyom Trishkin:
You must have already got it ready. How is it done there? I can't look it up - I'm writing from my mobile.

I apologise for the inconvenience.

//+------------------------------------------------------------------+
//| start                                                            |
//+------------------------------------------------------------------+
int start()
  {

а надо 

//+------------------------------------------------------------------+
//| start                                                            |
//+------------------------------------------------------------------+
int OnStart

  { 

But the file creates, not with the requested data,

result - one column filled with 17 rows of boolean true

There's a stringStringSetChar - swore at the beginning,

changed it toboolStringSetCharacter- that must be the reason for the boolean

//+------------------------------------------------------------------+
//| PrepareString                                                    |
//+------------------------------------------------------------------+
string PrepareString(string s)
  {
   bool exit = false;
   int index = 0;
   string str = s;
//----
   while(!exit)
     {
       index = StringFind(str, ".", index);
       if(index > -1)
           str = StringSetChar(str, index, ',');
       else
           exit = true;
     }
   return(str);
  }
Files:
VCSV.mq5  3 kb