Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 67
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
{
// Receives the number of bytes written to the file. Note that MQL can only pass
// arrays as by-reference parameters to DLLs
int BytesWritten[1]={0};
// Get the length of the string
int szData=StringLen(DataToWrite);
// Do the write
WriteFile(FileHandle,DataToWrite,szData,BytesWritten,0);
// Return true if the number of bytes written matches the expected number
return (BytesWritten[0] == szData);
}
I want to write a line to the file with translations to a new line, but it doesn't work, this code is from herehttps://www.mql5.com/en/forum/118999
this code writes a line with spaces after each letter, I need a replacement for FileWrite() but it works
Please read up on what a function is. Then you'll understand that the array declared in the function body will be local - out of sight of the rest of the program.
That is, I need 3 functions
1) where I declare it
2) which one I will use to add values to it
3) which one I will use to delete them from the database?
right?
That is, I need 3 functions
1) where I declare it
2) which one I will use to add values to it
3) which one I will use to delete them from the database?
correct?
Read it carefully.
Ok, make a void function that will write orders into a two-dimensional array (ticket + lot)
get a picture of this type
{
ticket=OrderSend(Symbol(),OP_BUY,(лот2 ордера+лот4 ордера),Ask,50,0,0,"",Magic,0,clrAzure);
Функция записи();
}
и если массив локальный то каким образом я буду оттуда вытаскивать данные в текущую команду?
ретурн не возвращает данные массивов, а если засунуть туда выражение извлечения его будет не видно
Ok, make a void function that will write orders into a two-dimensional array (ticket + lot)
get a picture of this type
{
ticket=OrderSend(Symbol(),OP_BUY,(лот2 ордера+лот4 ордера),Ask,50,0,0,"",Magic,0,clrAzure);
Функция записи();
}
и если массив локальный то каким образом я буду оттуда вытаскивать данные в текущую команду?
ретурн не возвращает данные массивов, а если засунуть туда выражение извлечения его будет не видно
Tell me please, why write the tickets and lots into an array at all, other than to learn how to use an array ? When you turn off your computer the whole array will crash, why make it so unreliable in the first place? Unless of course the point is to learn how to work with arrays...)
ok, find me 6 orders in an uneven grid the easy way, or 8 by ticketing
I need it as long as there is a grid of orders, then let it roll.
well the goal i stated in the code aboveok, find me 6 orders in an uneven grid the easy way, or 8 by ticketing
I need it as long as there is a grid of orders, then let it roll.
Well, I stated the goal in the code aboveHere, there's a chance to sort by several parameters, so a two-dimensional array is used.
I hope you will understand how to use it, if not - to freelance)
double SPosMass[][2];
void OnTick()
{
// Заполняем массивы
int b=-1,s=-1; // Объявим переменные с минусом
for(int i=0; i<OrdersTotal(); i++) {
if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if(OrderSymbol()==Symbol() && (OrderMagicNumber()==Magic || Magic<0)) {
if(OrderType()==OP_BUY) {
b++;
ArrayResize(BPosMass,b+1);
BPosMass[b][0]= (int)OrderOpenPrice();// Для сортировки = можно сортировать по: OrderProfit(), OrderLots(), OrderTicket(), OrderOpenTime()
BPosMass[b][1]= OrderTicket(); // Для чтения
}
if(OrderType()==OP_SELL) {
s++;
ArrayResize(SPosMass,s+1);
SPosMass[s][0]= (int)OrderOpenPrice();// Для сортировки = можно сортировать по: OrderProfit(), OrderLots(), OrderTicket(), OrderOpenTime()
SPosMass[s][1]= OrderTicket(); // Для чтения
}
}}} // конец записи массив
// Читаем отсортированный массив с тикетами
// Buy
if(b>0) { // Если он не пустой и больше двух элементов - [0], иначе будет ошибка: "Выход за пределы массива"
ArraySort(BPosMass, WHOLE_ARRAY, 0, MODE_ASCEND); // Отсортируем по первому измерению
// Работа с полученными данными
Comment("Самый старый Buy тикет: ", BPosMass[0][1],
"\nПоследний Buy тикет: ", BPosMass[b][1],
"\nПредпоследний Buy тикет: ", BPosMass[b-1][1]
);
} // end Buy
// Sell
if(s>0) { // Если он не пустой и больше двух элементов - [0], иначе будет ошибка: "Выход за пределы массива"
ArraySort(SPosMass, WHOLE_ARRAY, 0, MODE_ASCEND); // Отсортируем по первому измерению
// Работа с полученными данными
Comment("Самый старый Sell тикет: ", SPosMass[0][1],
"\nПоследний Sell тикет: ", SPosMass[s][1],
"\nПредпоследний Sell тикет: ", SPosMass[s-1][1]
);
} // end Sell
// Конец функции OnTick()
}
Here, there's a chance to sort by several parameters, so a two-dimensional array is used.
I hope you understand how to use it, if not, go to freelance)
how to get a dimensionless one beforehand, it doesn't work with empty values
It is dimensionless as it is, but it is two-dimensional, and you can put a dimensionless number of elements in two dimensions.
What are you doing anyway, do you have any idea what the result of the work you do should be? Or are you making logic up as you go along?