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

 
Alexander Layzerevich:

Fixed the MT5 code to send data to the Indicator:

But the error is the same.

Stop peeking into crap code written in mql4 and you'll get it quicker.

 
Igor Makanu:

Look at the project properties in Visual Studio, there should be a setting for which platform to compile dll - MT4 needs 32-bit code

PS: google find the VS setting

I tried to look for such a setup search engine gives out answers that like the opposite of 32 to 64 and in general and did not understand how to make this setting. If I understand a little here I have it by default 32 is

And I found some menu with a setting.

So I don't know if it defaults to 32 here.

 

Can you please tell me why the same code works in MT4 but not in MT5? In MT5 variable strNum always =1, but in MT4 counter ++ works as it should and strNum = number of line items in the file.

int strNum;
void OnStart()
  {
 FileNum();
 Alert1();
  } 

  void FileNum()
{
      int handle=FileOpen("File.csv",FILE_CSV|FILE_READ,';');
      strNum=0; 
      while(!FileIsEnding(handle))
{
      FileReadString(handle);
      strNum++;
      if(FileIsEnding(handle)==true)
      break;
}
      FileClose(handle);
}

      void Alert1()
{
      Alert (strNum);
}
 
Seric29:

Tried to search for such a setting search engine gives answers that like the opposite from 32 to 64 and in general did not understand how to make this setting. If I understand a little bit here is my default setting of 32

And I found some menu with a setting.

So I don't know if it's 32 by default here.

Also with libraries, there's the /MT or /MD thing, I get them mixed up all the time :-) This is also somewhere in the wilds of user-friendly studio

Show me the entire project, including everything you've done there in C++ and Mql. I don't think that it's a fierce copyright :-)
we'll tell you what's wrong, otherwise you'll strain everybody with telepathy for a long time.


 
Maxim Kuznetsov:

There's also the /MT or /MD library thing, I get them mixed up all the time :-) This is also somewhere in the wilds of user-friendly studios

Show me the whole project, including everything you've done in C++ and Mql. I don't think it's the worst copyright :-)
We will tell you what's wrong by the full code, otherwise you will strain everyone with telepathy for a long time


File with the .def extension

file with .cpp extension

into mql4, I simply dragged a file from the folder of the terminal Libraries

#import "dllmt42.dll"
 int _add(int a=0, int b=0);
#import

And then stupidly call the function, it just returns 18 and does nothing else, it's like an experiment to see if it works or not.

 
Seric29:

File with a .def extension

File with .cpp extension

I just copied file from terminal folder Libraries to mql4

And then I just call the function, it returns 18 and does nothing else, it's like an experiment to see if it works or not.

why do you add a dash to add? get rid of it.

all identifiers in all files should be strictly identical, no fancy age :-)

 
Alexey Viktorov:

Stop peeking into crap code written in mql4 and you'll get it quicker.

All, as you put it, "crap code" is written according to the basic language help.https://www.mql5.com/ru/docs/basis/function/call

It also says"A function cannot be declared inside another function."

That's exactly what it says. That's why it doesn't work.

That's why I'm trying to find out from experts how to call the function(Deviation(Kanal)). When it depends on call of function(double Envelopes(...))

upd: The issue has been partially resolved.
 
Maxim Kuznetsov:

Why do you add a __dash line to the add? Get rid of it.

all identifiers in all files should be strictly identical, no fantasies about the age :-)

Well, everyone did so according to the instructions and I did, now I'll remove it and see. All in all it worked, it returned 18. Thank you, I'll keep experimenting.

 
Alexander Layzerevich:

All, as you put it, "crap code" is written according to the basic language help.https://www.mql5.com/ru/docs/basis/function/call

It also says"A function cannot be declared inside another function."

That's exactly what it says. That's why it doesn't work.

That's why I'm trying to find out from experts how to call the function(Deviation(Kanal)). When it depends on call of indicator function(double Envelopes(...))

upd: The issue has been partially resolved.

You have already called and passed the value returned by theDeviation(Kanal) function to theEnvelopes(........) function

and in theEnvelopes(........) function itself, you declare the last parameter, which will take this value


similarly

double Envelopes(string symb, ENUM_TIMEFRAMES tf, int period, int shift, int method, int price, int buff, double Dev)
{
  double buf[1];
  int handle=iEnvelopes(Symbol(), tf, period, shift, method, price, Dev);
   if(handle<0)
   {
    Print("Failed to create handle ATR, Error: ",GetLastError());
    return(WRONG_VALUE);
   } else
   {
    if(CopyBuffer(handle,buff,0,1,buf)<0)
    {
     Print("Failed to copy data from the indicator ATR, Error: ",GetLastError());
     return(WRONG_VALUE);
    }
   }
   return(buf[0]);
}
 
KrasAleks:

Greetings all. Good luck in life and profit in work.

I appeal for help (unexpected, huh? :) )

...................................................

And that's where I got stuck :). What to use instead of GetProfitOpenPosInPoint(Symbol(),OP_BUY,Magic). The_failure_level(Symbol(),OP_BUY,Magic) should be used but how to get it...


I will be glad if you will help me.
Z.U. If you give advice, I beg you, keep in mind that I am still very green, do not be lazy to give me a little more detail, you know, like if: FOREST THERE, do not forget to point out the direction <------ || ------>.

Thanks for your attention :).

Good morning, afternoon, evening, night (underline).

I don't mean to be rude, but I'll ask you a question. I've been thinking about my mess.... I'm supposed to need the last OP_BUY && OP_SELL, his Magik || ticket || open_price..... Am I right? If I find the last order, I can in theory calculate the distance from it to the current ask\bid. Downloaded a couple of "averagers" here, imho there should be something similar, if not identical, ..... only to realise I found what I was looking for..... :)

If no one minds :), I will continue to hope for your advice, at least a reference to the source of the information I need (if it's notKovalev's book, I started with it 3 days ago).