I'm having a hard time learning mql5, but I realized that I don't understand the financial part of it, so I don't even know what to write. I have some basic knowledge, but I don't know how to use it. Please advise good people who have been in the same situation, how did they find a way out?
dzhabrailov: I'm having a hard time learning mql5, but I realized I don't understand the financial part of it, so I don't even know what to write. I have some basic knowledge, but I don't know how to use it. Can you advise the good people who have been in the same situation?
What does "financial part" mean? Trading functions? OrderSend() is not clear how to organize?
That is exactly what is clear, but you cannot always buy cheaper and sell more expensive. When to enter a deal when to exit it and so on, that's what I mean.
dzhabrailov: That is exactly what is clear, but you cannot always buy cheaper and sell more expensive. When to enter a deal when to exit it and so on, that's what I mean.
Well, this is not a part of the notion of programming. This is the art of trading. They teach it, but I do not believe in the success of such trainings.
To your"ArraySortBubbleTwoDims"
To your"ArraySortBubbleTwoDims".
Anyway, I've expanded the loop and the issue is solved. But I would still like to see a normal solution in the form of a standard function
To your"ArraySortBubbleTwoDims".
Anyway, I've expanded the loop and the issue is solved. But I would still like to see a normal solution in the form of a standard function
//| sTestSort.mq5 |
//| Copyright 2017, Artem A. Trishkin, Skype artmedia70 |
//| https://login.mql5.com/ru/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, Artem A. Trishkin, Skype artmedia70"
#property link "https://login.mql5.com/ru/users/artmedia70"
#property version "1.00"
//---
#define TWO_DIM (2)
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
double array[][TWO_DIM];
ArrayResize(array,10);
for(uchar i=0; i<10; i++) {
array[i][0]=i*10;
array[i][1]=rand();
}
Print("Перед сортировкой");
for(uchar i=0; i<10; i++) Print("array[",i,"][0]=",array[i][0],", array[",i,"][1]=",array[i][1]);
Print("Сортировка по первому измерению по возрастанию");
ArraySortBubbleTwoDims(array);
for(uchar i=0; i<10; i++) Print("array[",i,"][0]=",array[i][0],", array[",i,"][1]=",array[i][1]);
Print("Сортировка по первому измерению по убыванию");
ArraySortBubbleTwoDims(array,0,1);
for(uchar i=0; i<10; i++) Print("array[",i,"][0]=",array[i][0],", array[",i,"][1]=",array[i][1]);
//---
Print("Сортировка по второму измерению по возрастанию");
ArraySortBubbleTwoDims(array,1);
for(uchar i=0; i<10; i++) Print("array[",i,"][0]=",array[i][0],", array[",i,"][1]=",array[i][1]);
Print("Сортировка по второму измерению по убыванию");
ArraySortBubbleTwoDims(array,1,1);
for(uchar i=0; i<10; i++) Print("array[",i,"][0]=",array[i][0],", array[",i,"][1]=",array[i][1]);
}
//+------------------------------------------------------------------+
//| Пузырьковая сортировка двумерного массива |
//+------------------------------------------------------------------+
template<typename T>
void ArraySortBubbleTwoDims(T& array[][TWO_DIM], int sort_dimension=0, int sort_direction=0) {
T t=0;
int k=ArrayRange(array,1); // Количество колонок
int n=ArrayRange(array,0); // Количество строк
//---
if(sort_dimension<0) sort_dimension=0;
if(sort_dimension>k) sort_dimension=k;
//---
for(int i=n-1; i>0; i--) {
for(int j=0; j<i; j++) {
//--- по возрастанию
if(sort_direction==0) {
if(array[j][sort_dimension]>array[j+1][sort_dimension]) {
for(int e=0; e<k; e++) {
t=array[j][e];
array[j][e]=array[j+1][e];
array[j+1][e]=t;
}
}
}
//--- по убыванию
else {
if(array[j][sort_dimension]<array[j+1][sort_dimension]) {
for(int e=0; e<k; e++) {
t=array[j][e];
array[j][e]=array[j+1][e];
array[j+1][e]=t;
}
}
}
}
}
}
//+------------------------------------------------------------------+
Checking script:
Thanks, but my code is magic(
Error: 'mas' - parameter conversion not allowed e.mq5 2129 25
Thanks, but my code is magic(
Error: 'mas' - parameter conversion not allowed e.mq5 2129 25
Your mas has a second dimension of 3. You need 2.
Bottom line:
void PosBySort(double &mas[][3])
I'm having a hard time learning mql5, but I realized I don't understand the financial part of it, so I don't even know what to write. I have some basic knowledge, but I don't know how to use it. Can you advise the good people who have been in the same situation?
That is exactly what is clear, but you cannot always buy cheaper and sell more expensive. When to enter a deal when to exit it and so on, that's what I mean.