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

 
MakarFX #:

So that you can write yourself a reminder - what's the function

:))) as if I can't do it myself when I need to: insert two slashes and write a couple of words. Have you tried writing something in that frame? That forward slash on the right will go to the right by the number of characters you typed, but what if you need to write more than one line? Instead of doing something, I have to waste my time on drawing frames. It's just that the ide imposes some kind of sick vision of how it should be.

 
Nerd Trader #:

:))) as if I can't do it myself when I need to: insert two slashes and write a couple of words. Have you tried writing something in that frame? That forward slash on the right will go off by the number of characters you typed to the right, but what if you need to write more than one line? Instead of doing something, I have to waste my time on drawing frames. I'm just imposing some sick vision of how it should be.

Put two slashes in front of the function and you're good to go.

//
int OnCalculate (const int rates_total,
                 const int prev_calculated,
                 const datetime& time[],
                 const double& open[],
                 const double& high[],
 
MakarFX #:

Put two slashes in front of the function and you're good to go

I already wrote above that if there is an empty line between the comment and the function, a frame will be inserted.
 

When the button is clicked, a horizontal line is created. They are recreated with a different colour depending on the position of the cursor in relation to the price. The problem is: yellow and grey lines are flickering and constantly being created (green is OK) when the cursor is at the appropriate position away from the price. Similar code changing only line colour property, not recreating it, works correctly.

The logical NOT here is in its place, i.e. instead of writing == 0.

void OnChartEvent(const int id, const long &lparam, const double &dparam, const string &sparam)
{
  ...
  ...
  ...
  if(ObjectGetInteger(0,"Button Stop Order",OBJPROP_STATE)){
    int x = (int)lparam;
    int y = (int)dparam;
    //Переведём координаты X, Y в дату и время
    if(ChartXYToTimePrice(0,x,y,window,dt,price)){
      //Линия меняет цвет с зелёного на желтый
      if(price < Bid){
        if(!ObjectFind("Buy Stop") || !ObjectFind("not allowed")){
          ObjectDelete(line_name);
          line_name = "Sell Stop";
          CreateLine(line_name, clrYellow);
        }      
      }
      //Линия меняет цвет с желтого на зелёный
      if(price > Ask){
        if(!ObjectFind("Sell Stop") || !ObjectFind("not allowed")){
          ObjectDelete(line_name);
          line_name = "Buy Stop";
          CreateLine(line_name, clrGreen);
        }
      }
      //Линия меняет цвет на серый если в зоне спреда
      if(price > Bid && price < Ask){
        if(!ObjectFind("Buy Stop") || !ObjectFind("Sell Stop")){
          ObjectDelete(line_name);
          line_name = "not allowed";
          CreateLine(line_name, clrGray);
        }
      }
      //Прикрепляем линию к курсору
      if(id == CHARTEVENT_MOUSE_MOVE)
        if(ObjectMove(0,line_name,0,0,price))
          ChartRedraw(0);
    }
  }else if(ObjectFind(line_name) == window) Print(ObjectDelete(line_name));
 
Nerd Trader a horizontal line is created. They are recreated in a different colour depending on the position of the cursor in relation to the price. The problem is: yellow and grey lines are flickering and constantly being created (green is OK) when the cursor is at the appropriate position from the price. Similar code changing only line colour property, not recreating it, works correctly.

The logical NOT here is in its place, i.e. instead of writing == 0.

ObjectFind is an int, not a bool
 
Nerd Trader #:

Because it really pisses me off when you decide to move to a native mql4 environment and there you go! Would you like a frame? And we will sell it anyway.

You have to use Makar's method to get what you want.

MakarFX #:

I didn't know about the styles, so I formatted them the way I wanted to read them.

 
MakarFX #:
ObjectFind is an int, not a bool
in this case there is no difference "!" or "==0"
 
Nerd Trader #:
in this case there is no difference "!" or "==0"

There is a difference!!!

      if(!ObjectFind("Buy Stop"))Print("All right Христофор Бонифатич!");
      else Print("Something is wrong!");
      if(ObjectFind("Buy Stop")!=0)Print("All right Христофор Бонифатич");
 
Nerd Trader #:
in this case there is no difference "!" or "==0"
if(!ObjectFind("Buy Stop"))

This query goes like this:

Vasily Ivanovich Chapayev and Petka are flying in an aeroplane, and suddenly Vasily Ivanovich, sitting at the pilot's wheel, cries out:

"Petya, the instruments!"

Petya replies: "Thirty-eight."

Vasily Ivanovich: "Thirty-eight what?"

Petya: "What about the instruments?"

 
MakarFX #:

This request looks like this:

No Makar, it looks like this:

The ObjectFind() function returns the number of the main window. And this number is 0. On the other hand, 0 == false, so it follows that if the function returns 0, it still returns false. Of course, I would not use this because if the function returns -1, i.e. an error, we may consider the location of the object not in the main window. On top of that, you never know what fixes will be made...

In general, do not argue and do not learn to do so ...