I am trying to make this 3D chart for x=time, y=price, z=volume.
Sorry for simple questions I'm very new to coding.
Sorry for simple questions I'm very new to coding.
//+------------------------------------------------------------------+ //| 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 //+------------------------------------------------------------------+ //| 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); } //+------------------------------------------------------------------+ //| GenerateCsv | //+------------------------------------------------------------------+ int GenerateCsv(string fileName, int arraySizeX, int arraySizeY, int arraySizeZ, double arrayIndexX[], double arrayIndexY[], double arrayIndexZ[]) { int handle = FileOpen(fileName, FILE_CSV|FILE_WRITE, ' '), x, y, z; 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 + arrayIndexY[y]; str = str + ";"; } FileWrite(handle, PrepareString(str)); for(z = 0; z < arraySizeZ; z++) { str = str + arrayIndexZ[z]; str = str + ";"; } FileWrite(handle, PrepareString(str)); { } FileClose(handle); return(handle); } //+------------------------------------------------------------------+
Just a little bug.
At the line
arrayZ[x,y]=MathSin(arrayIndexX[x]+arrayIndexY[y]);
the code must be:
arrayZ[x,y]=MathSin(arrayIndexX[x]) + MathSin(arrayIndexY[y]);
if you see the results of the Z array there are greater than 1 and it's not possible in a Sinus, but in fact they approach to 2, the sum of the x and y sinus...
Hello,
I would like to ask for support.
When I drag&drop the script into a price chart no new file "test.csv" appeared
there.
I've also corrected the line as specified in the comment by "moneymakers", had no compiling errors and seemingly everything is placed where it should be.
Kind regards,
serendippo

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
New article Three-Dimensional Graphs - a Professional Tool of Market Analyzing has been published:
In this article we will write a simple library for the construction of 3D graphs and their further viewing in Microsoft Excel. We will use standard MQL4 options to prepare and export data into *.csv file.
All traders operate with constantly changing prices and quotes. Everyone searches correspondences and regularities. We analyze volumes, values of different indicators and many other parameters. I don't think it necessary to persuade you of MQL4 benefits in terms of market analysis. You simply write a script and make conclusions based on results. Usually analysis is conducted upon charts or graphs that reflect a certain correspondences of two variables. All this is fine, of course, but sometimes we need to find the correspondences of three variables and visualize them. For this purpose 3D graphs and their analysis are used all over the world. Such approach saves your time and money.
In this article we will write a simple library for the construction of 3D graphs and their further viewing in Microsoft Excel. We will use standard MQL4 options to prepare and export data into *.csv file
Author: Antoniuk Oleg