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

 
Artyom Trishkin:

There is no need to guess. You have to think and understand what is being done and for what purpose. When something needs to be written and when it doesn't need to be.

It is thinking that the print should contain a string and any numeric value should be cast to a string.
But this example showed that the compiler is getting sluggish. And how can we not guess when the compiler skips and when it doesn't.

 
Roman:

It would seem that the print should be converted to string, so any numeric value must be cast to string.
But this example showed that the compiler gets obtuse. How not to guess when the compiler skips and when it doesn't.

Again - the code here - what's not clear?

ZS. If it's about this:

Print((string)(uint)PeriodSeconds(PERIOD_MN1)*1000)

... I didn't check it - just retyped it in the post.

Make functional conversion to string:

Print(string((uint)PeriodSeconds(PERIOD_MN1)*1000));
 

Friends!

I'm struggling with the problem of connecting a DLL to MQL. I am describing my problem:

1. At first I tried to write a .dll library in C#. I have found that MQL4 does not "eat" such libraries, since all methods inside dll are closed, if written in C#. I started to actively search for a solution to the problem. I found several variants on the Internet, like the connection of the "DLL Export" library, downloaded from NuGet. Tried different ways, it didn't work. I really don't want to have a "fragile" solution to this problem, by the principle "it works today and not tomorrow". Tried it this way, and there's actually a lot of how it works otherwise:

using System.Runtime.InteropServices;
using RGiesecke.DllExport;

[DllExport("Good", CallingConvention.Cdecl)] // + заменял на просто [DllExport] - не помогает
public static string Good() {

   return "GHBBBGGDDDD !!!!! РУССКИЙ! :) " + 5.ToString();
}


2. Figured out that I'd most likely have to write a stable-working C++ library. Plugged it in from the 1st time, test queries went through without any problems. But when I started trying to return a text message (to MQL) with a method (from DLL), I encountered a new problem - the MQL response I got was"?????‡?-". I tried to decode the message, but it didn't work! I tried to return the value via a function parameter - I got "?". I searched a lot of things and still haven't found a solution. This is the variant I've settled on, but it returns question marks:

extern "C" __declspec(dllexport) char* __stdcall ToString(char* &str)
{
        str = " - 889 - dsa - просто!";
        return "--- Привет! ---";
}


I'm getting an answer in the form of:

Decoding doesn't help...


What is needed essentially:

1) is there a real solution to this problem via C#? I need a stable beautiful solution! Half-measures, even if they work now, but may fall off with a new build, is not an option.

2) If there is no C# solution, go through C++. How to properly send messages in both directions without losing quality? (MQL - DLL - MQL). I need the variant that equally works with MT4 and MT5.

 
Artyom Trishkin:

Again - code here - what is not clear?

It is not clear why constants from H1 and above are returned that do not correspond to the period as before H1

Print("PERIOD_M1=",PERIOD_M1);
Print("PERIOD_M5=",PERIOD_M5);
Print("PERIOD_M30=",PERIOD_M30);
Print("PERIOD_H1=",PERIOD_H1);
2020.04.10 03:47:03.627 VP (EPM20,H4)   PERIOD_M1=1
2020.04.10 03:47:03.627 VP (EPM20,H4)   PERIOD_M5=5
2020.04.10 03:47:03.627 VP (EPM20,H4)   PERIOD_M30=30
2020.04.10 03:47:03.627 VP (EPM20,H4)   PERIOD_H1=16385
2020.04.10 03:47:03.627 VP (EPM20,H4)   PERIOD_H4=16388

The same is returned by the _Period variable.

 
Roman:

It is not clear why constants from H1 and above are returned that do not correspond to the period as before H1

The same is returned by the _Period variable.

 
Artyom Trishkin:

Artyom don't freak out ))
Why to M30 exactly the values of TF are displayed
1
5
30

And on H1 it starts with 16385
Well, it's not logical to return the value to minutes first, and then to the hell.
And it doesn't fit the description in the help for _Period as a timeframe return value.

 
Roman:

Artyom don't freak out ))
Why to M30 exactly the values of TF are displayed
1
5
30

And on H1 it starts with 16385
Well, it's not logical to return the value to minutes first, and then to the hell.
And it doesn't fit the description in the help for _Period as a timeframe return value.

Timeframevalue. Not the number of minutes. Not the number of seconds, not the number of geese at Baba Nyura's, but the value of the timeframe.

Документация по MQL5: Проверка состояния / Period
Документация по MQL5: Проверка состояния / Period
  • www.mql5.com
Проверка состояния / Period - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Artyom Trishkin:

The value of the timeframe. Not the number of minutes. Not the number of seconds, not the number of geese at Baba Nyura's, but the value of the timeframe.

This is what we are talking about, that constants must be equal to timeframe values!
And carry the logical and mathematical meaning of the correspondence.
Because these values are used in the calculations.

M1 = 1
M5 = 5
M30 = 30
H1 = 60
H4 = 240
D1
= 1440

Otherwise the meaning of the returned values is lost.
Therefore it is a bug in my opinion.

 
Как за 10 минут написать DLL библиотеку для MQL5 и обмениваться данными?
Как за 10 минут написать DLL библиотеку для MQL5 и обмениваться данными?
  • www.mql5.com
Так уж сложилось, что сейчас мало кто из разработчиков помнит, как написать простую DLL библиотеку и в чем особенности связывания разнородных систем. Я постараюсь за 10 минут на примерах показать весь процесс создания простых DLL библиотек и раскрою некоторые технические детали нашей реализации связывания. Демонстрация будет на примере Visual...
 
Artyom Trishkin:

I'm surprised you have the patience to repeat it all for such a long time, and in the morning... Although you're already in the morning after another sleepless night.))

At least put him in quarantine for 24 hours to read the documentation carefully. That's a shame... This is the first time such an ace in the C-language varieties has said such nonsense. And this is the first time it's all been explained...

Just imagine that this was figured out in Service Desk. They probably don't have that kind of balance there, that's why they closed it.

Reason: