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

 
Seric29:
How to implement datetame and color type variable in a C++ dll library? How to call Print() function in dll what to replace it with, because c++ doesn't have it, and can you do it at all, because there is no debugging in mql4 and you make mistakes often or it's hard to write something the first time, what can you do?

have you tried pressing F1?

"The datetimetype is designed to store the date and time as the number of seconds elapsed since January 01, 1970. It occupies 8 bytes in memory."

with color type - practice it yourself :-)

---

When debugging dll, instead of Print function - print to file and look in it.

 
Maxim Kuznetsov:

have you tried pressing F1?

with colour type - practise it yourself :-)

---

When debugging dll, instead of Print function - print to file and look in it.

I understand about Print(), thanks for the tip, and the console can be output, because I can't work with files in C++ and here, and as for datetime, I do not understand why you wrote it at all?

 
Seric29:

I understand about print(), thanks for the advice, and the console can be output, because I do not know how to work with files in C++ and here yet, and as for datetime, I did not understand why you wrote it at all?

It's all about representation in C/C++

it's an 8-byte unsigned integer unixtime, i.e. uint64_t or time64_t as you prefer

 
Maxim Kuznetsov:

and it says everything about representation in C/C++

it is an 8-byte unsigned integer unixtime, i.e. uint64_t or time64_t as you prefer

neither uint64_t nor time64_t does not work, I tried to write <uint64_t > too. And how to work with colours is also not clear, I did not find explanations in network too, I am engaged in this question 2-th year?

 
Seric29:

neither uint64_t nor time64_t works I tried to write <uint64_t > also does not work. And I don't know how to work with colours either, I haven't found any explanations on the web, I've been dealing with this issue for 2 years.

You should just study C/C++ first, without MetaTrader and DLL. Otherwise you will be nothing but frustration and wasted effort.

#include <ctime>

// или для uint64_t (что на мой взгляд вернее)

#include <cstdint>

see http://www.cplusplus.com/refe rence/

Reference - C++ Reference
Reference - C++ Reference
  • www.cplusplus.com
The elements of the C language library are also included as a subset of the C++ Standard library. These cover many aspects, from general utility functions and macros to input/output functions and dynamic memory management functions: Containers Input/Output Stream Library Provides functionality to use an abstraction called streams specially...
 
Maxim Kuznetsov:

You should just learn C/C++ first, without MetaTrader and DLL. Otherwise you'll be frustrated and working in vain.

#include <ctime>

// или для uint64_t (что на мой взгляд вернее)

#include <cstdint>

see http://www.cplusplus.com/refe rence/

If I understand correctly, it takes extreme points and counts them in seconds, but I don't know how to display the usual format. I'd like some examples. And how to work with colours?

 

It is not clear how to generate a date in this format 2008.09.23 00:00 if the variable time_t stores seconds?

time_t Data()
{ return 100;} Что функции в с++ так выглядят
 

Whichever example I can find on the internet doesn't even compile here's one of them

int main()
{ 
  time_t rawtime;
  struct tm * ptm;
  time( &rawtime );                                     // определить текущую дату в секундах
  ptm = gmtime( &rawtime ); 
return 0;}
Obviously, it's impossible to understand anything in this way.
 

Hello.

Can you tell me why when I open a sellstop, if I specify a variable in the price parameter that stores the desired price, it will swear.


int ZeroBufer;              // ticket zero
struct Order_Data_S // Структура которая заполняется по мере поступления данных.
  {
   int               ticket;
   double            price;
  };
Order_Data_S OrderBufer_S[100];

void OnTick()
  {
  double prise_s = MarketInfo(Symbol(), MODE_BID);
  double zero = prise_s;
  OrderSelect(OrderBufer_B[0].ticket,SELECT_BY_TICKET,MODE_TRADES);  //return value of 'OrderSelect' should be checked  

   if(OrderType() == 0) // открыт bay ордер
     {
      ZeroBufer = OrderSend(Symbol(),OP_SELLSTOP,lots,OrderBufer_S[0].price),3,0,0,"bs2",2,0,clrRed);  // sell stop на шаг сетки.  // 'OrderSend' - wrong parameters count. 
      //',' - unexpected token. И еще 100500 ошибок на эту строку. OrderBufer_S[0].price не пустой. Там уже находится нужная цена.
      
      if(OrderSelect(ZeroBufer,SELECT_BY_TICKET,MODE_TRADES) != true)
        {
         ZeroBufer = OrderSend(Symbol(),OP_SELLSTOP,lots,zero),3,0,0,"bs2",2,0,clrRed);
        }  // повторить, пока не откроет
     }
     }
     
     // Если вместо "OrderBufer_S[1].price" воткнуть другую переменную "zero" - в которой хранится цена, то он снова ругается, но гораздо меньше.
     // Его не устраивает эта переменная

What should I do in this case?

And one more question. What is the best way to check if the order is opened next? I.e., if this is the first order, then the current code for selecting trades from the stack and checking its type will do. But later on, a thought has come up that there might be some confusion. If there is more than one order, how do we know if this order has just opened or has already been there for a long time? I checked the forum and they advise to use the price as a basis. We should try to determine if there is an order at this price +/- deviation. But again, the same question. How do we know if this is a new or an old order? Whether the order is opened from a pending one or the order already existed there and the price is simply at its level.

 
Gilmor:

Hello.

Can you tell me why when I open a sellstop, if I specify a variable in the price parameter that stores the desired price, it will swear.


What should I do in this case?

Keep an eye on the pairing of brackets.

ZeroBufer = OrderSend(Symbol(),OP_SELLSTOP,lots,OrderBufer_S[0].price),3,0,0,"bs2",2,0,clrRed);