Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1069

 
Is it possible to export from C++ and import datetime functions to mql? I suspect that it is not possible for functions to work only in the shell in which they are created, but I would like to know from knowledgeable people?
 
Viatcheslav Pashkov:

that's exactly what I read.

But it must have been written for those who knew but had forgotten.

That information didn't help me one bit.

Can you give me a simple example?

template<typename T>
T Add(T first,T second) {return first+second;}
 
Seric29:
Is it possible to export from C++ and import into mql functions like datetime? I suspect it's not possible for functions to work only in the shell they are created in, but I would like to ask some knowledgeable people?

You can. Datetime is just 64 bits, which the mql compiler already perceives as POSIX time. So, nothing prevents you from creating functions in dll that will return INT64 with the number of seconds that have passed from 00:00:00 01.01.1970.

The dll will contain:

INT64 Foo(...){...}

and you can declare when importing

datetime Foo(...);

 

I can't sign up as a seller for a week, there is no sign up button. I couldn't pay twice before (it took me 3 weeks to re-register) and it took me a month+ to sign up as this account.

what's the tambourine to get the button? https://www.metatrader5.com/ru/terminal/help/market/market_sell

Как стать продавцом - Маркет - магазин приложений - Справка по MetaTrader 5
Как стать продавцом - Маркет - магазин приложений - Справка по MetaTrader 5
  • www.metatrader5.com
Торговая платформа обладает многомиллионной аудиторией трейдеров. Став продавцом в Маркете, вы получите прямой доступ к ним, ведь ваш продукт появится прямо в торговой платформе на витрине Маркета. Помимо этого все продукты доступны на витрине Маркета на сайте MQL5.community. Как зарегистрироваться в качестве продавца # Чтобы иметь возможность...
 
Vladimir Simakov:

You can. Datetime is just 64 bits, which the mql compiler already perceives as POSIX time. So, nothing prevents you from creating functions in dll that will return INT64 with the number of seconds that have passed from 00:00:00 01.01.1970.

The dll will contain:

INT64 Foo(...){...}

and it is possible to declare when importing.

datetime Foo(...);

Thanks for the reply, kept my spirits up.

I've created so many topics on cyberforum on date implementation. No one has given any clear answers. And what libraries and resources do I need to connect to generate date from C++ side in dll, I found different codes on the net and inserted them into compiler, they didn't even compile?

 
Is it possible to pass an array to c++ and change its parameters such as number of rows and columns. In C++ itself this is done without problems, but when I pass an array from mql, it does not change the question why?
 
Seric29:

Thanks for the reply, kept my spirits up.

I've created so many threads on cyberforum on the implementation of the date. No one has given any clear answers. What libraries and resources should I use to generate date from++ side in dll, I found different codes on the net and inserted them into compiler, but they didn't even compile?

I can only quote the classics: "Saw Shura...". First of all, figure out how the OS works with time: https://docs.microsoft.com/en-us/windows/win32/sysinfo/time-functions

When you figure it out, everything will be easy and simple, but - this is your way and no one will invest knowledge in you, only yourself.

PS. Less mindless Copy-Paste in the first steps, get into the nitty-gritty right away.

Time Functions - Win32 apps
  • 2018.05.31
  • mcleanbyron
  • docs.microsoft.com
The following functions are used with system time.
 
Vladimir Simakov:

I can only quote the classics: "Saw Shura...". For starters, figure out how the OS works over time: https://docs.microsoft.com/en-us/windows/win32/sysinfo/time-functions

When you understand it, everything will be easy and simple, but - this is your way and no one will invest knowledge in you, only yourself.

PS. Less mindless Copy-Paste on the first steps, get into the subtleties right away.

Are these ready-made functions to work with time or you need additional libraries, I just found a lot of things but didn't understand how to work with it. Do you have any links to youtube videos? I've never seen any video on the Internet about working with date, I've found either complicated or non-functional text information and no video?

I also don't understand why c++ code for mql4 doesn't work.

// ConsoleApplication5.cpp: определяет экспортированные функции для приложения DLL.
//со стороны mql объявляем массив формата int Mas[1] 

#include "stdafx.h"
#include <conio.h>
#include <iostream>

using std::cout;
using std::endl;
using std::cin;

using namespace std;//пытался выводить в консоль инфу но не работает может можно выводить в файл

#define _DLLAPI extern "C" __declspec(dllexport)


//данный пример работает в с++ но не работает в mql4
void Perenapr(int *&mas){// принимает массив как указатель на ссылку
int *arr=new int[10];// создаём новый массив/ новый участок памяти куда будем перенаправлять указатель со старого участка
for(int y=-1;++y<5;)//присваиваем элементы
arr[y]=y+1;
mas=arr;// перенаправляем указатель на новый участок памяти в результате со стороны mql указатель не меняется
// создаётся впечатление что в с++ из mql массив передается по значению а изменить форму массива из
// mql нельзя только из самого mql
}
_DLLAPI int __stdcall  test(int q,int w){
        return(189);}

_DLLAPI void __stdcall PriomMas(int mas[]){// данная функция принимает массив
Perenapr(mas);//данная функция перенаправляет указатель массива на ссылку указатель int *&mas
}


This example works in c++ but not in mql4. I wonder if you can change arrays with external programs or they are static and change only in mql/

 
Seric29:

Are these ready-to-use functions for working with time or do you need additional libraries, I've found many things but haven't figured out how to work with them. Do you have any links to youtube videos? I've never seen any video on the Internet about working with date, I've found either complicated or non-functional text information and no video?

I also don't understand why c++ code for mql4 doesn't work.


This example works in c++ but not in mql4. I wonder if you can change arrays with external programs or they are static and change only in mql/

Do not try to write a DLL in a language you do not know.

You will save a lot of nerves and time by taking a couple of training courses beforehand.

With enough diligence and determination, it's only a couple of weeks. You can hang a couple of nice certificate papers on the wall at the same time

 
Seric29:

Are these ready-to-use functions for working with time or do you need additional libraries, I've found many things but haven't figured out how to work with them. Do you have any links to youtube videos? I've never seen any video on the Internet about working with date, I've found either complicated or non-functional text information and no video?

I also don't understand why c++ code for mql4 doesn't work.


This example works in c++ but not in mql4. I wonder if you can change arrays with external programs or they are static and change only in mql/

IMHO of course, but there is an opinion and I support it

Learning from videos, examples, forums, shouting help-me etc is a direct path to a moncey coder. Only textbooks, only docs, only sleepless nights and litres of coffee in search of a solution will make a coder a developer.

Reason: