Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 465

 
Mr.Dmitry:

Hello. I have recently started studying MQL4 and came across the following misunderstanding.

As you can see in the example below, when the highest candle in the bar reaches 1.3058, the order should close. The order is closed according to the conditions but the close price is not 1.3058(it might be 1-3 pips higher). So, how do we close correctly? Does it closeat 1.3058?

You can't. The MT has a slippage, which is always in the broker's favour.
 
Mr.Dmitry:

Hello. I have recently started studying MQL4 and came across the following misunderstanding.

As you can see in the example below, when the highest candle in the bar reaches 1.3058, the order should close. The order is closed according to the conditions but the close price is not 1.3058(it might be 1-3 pips higher). So, how do we close correctly? Youwant your order to close at 1.3058?

Well, imagine that on the last tick the price was 1.3057, and on the current tick it is 1.3059.

Don't say later that the order didn't close. You are not doing the check correctly. You have to do it on "more or equal" or "less or equal" and nothing else.

 
artmedia70:

Imagine a situation where on the last tick the price was 1.3057 and on the current tick it became 1.3059.

Do not say that the order is not closed. You check it incorrectly. You should check for "more or equal" or "less or equal".


That's what I do >=. The above is only an example (excuse the tautology) and the issue is not that the order is not closed, but that it is closed not as I would like it to be.

borilunad:
No way, MT provides for slippage-Slippage, which is always in favour of the broker.
So there is no way to do it at all? Sad (((.
 
Zhunko:
You could write a script that draws this line. Bind this script to a hotkey.


Thanks. I'll give it a try.
 
Mr.Dmitry:

This is what I do >=. The above example is just an example (excuse the tautology) and the issue is not that the order does not close, but that it does not close the way I would like it to.

I mean there is no way out at all? Sad ((!)
If you set Stop Loss finally, you got to breakeven, started trawling and the price suddenly turned in the opposite direction and on this move the order is closed by Stop Loss not in profit, but in loss! Slippage+expanded spread=:(((
 

Good evening everyone!

Can you tell me what I'm doing wrong?

int start()

{

//----

ObjectCreate("trendln1",OBJ_TREND,0);

ObjectSet("trendln1",OBJPROP_COLOR,Red);

//----

return(0);

}

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!P.s. I tried to write a script for calling the trend line so that it would then be possible to assign a hotkey to appear the trend line.

 
okvseok:

Good evening everyone!

Can you tell me what I'm doing wrong?

int start()

{

//----

ObjectCreate("trendln1",OBJ_TREND,0);

ObjectSet("trendln1",OBJPROP_COLOR,Red);

//----

return(0);

}

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!P.s. I tried to write a script for calling the trend line so that it would then be possible to assign a hotkey to appear the trend line.

You should at least specify some coordinate when creating an object.

// Формирование линии
int fLine(string Name            // Префикс имени
         ,string Text            // Префикс описания
         ,int Number             // Номер
         ,int Bar1,double Price1 // Первая точка
         ,int Bar2,double Price2 // Вторая точка
         ,int Bar3,double Price3 // Вспомогательная точка
         ,color Цвет
         ,int Стиль=STYLE_SOLID  // Сплошная
         ,int Видимость=0        // Только на текущем таймфрейме
         ,bool Луч=false
         ,int Толщина=1
         ,bool Фон=true ){
   int Error;
   datetime Time1=Time[Bar1],
            Time2=Time[Bar2];
   if( Number>0 ) Name=Name+Number;
   if( Bar1<Bar2
    || Bar2<LastBar
    || Price1<Zero
    || Price2<Zero ){
      Error=MyError;
      if( РежимОтладки && ПечататьПредупреждения ) Print("*     "+Name+" не создан, параметры: "+DoubleToStr(Price1,Digits)
                                       +" ("+Bar1+"/"+TimeToStr(Time1)+")..."
                                       +DoubleToStr(Price2,Digits)+" ("+Bar2+"/"+TimeToStr(Time2)+")");
      return(Error);
   }
   Error=fObjectDelete(Name);
   if( Error>0 && Error<MyError ){
      return(Error);
   }
   if( ObjectCreate(Name,OBJ_TREND,0,Time1,Price1,Time2,Price2,Time[Bar3],Price3) ){
      if( Text!="" && Number>0 ){
         Text=Text+Number;
         Фон=true;
      }
      if( !ObjectSetText(Name, Text)
       || !ObjectSet(Name, OBJPROP_COLOR, Цвет)
       || !ObjectSet(Name, OBJPROP_STYLE, Стиль)
       || !ObjectSet(Name, OBJPROP_RAY, Луч)
       || !ObjectSet(Name, OBJPROP_TIMEFRAMES, Видимость)
       || !ObjectSet(Name, OBJPROP_WIDTH, Толщина)
       || !ObjectSet(Name, OBJPROP_BACK, Фон) ){
         Error=GetLastError();
         if( !РежимОтладки ) PlaySound("alert.wav");
         Print("***** "+Name+" - ошибка модификации параметров "+Error);
   }  }
   else{
      Error=GetLastError();
      if( !РежимОтладки ) PlaySound("alert.wav");
      Print("***** "+Name+" - объект не создан, ошибка "+Error);
   }
   return(Error);
}
 
tara:

You should at least specify some coordinate when creating an object.


and if I want to specify the coordinate already with the mouse. I just need to call the trend line itself, but it hasn't worked out yet. Is this possible?
 
okvseok:

and if I want to point the coordinate already with the mouse. I just need to call the trend line itself, but not yet triggered. Is it possible?

It's not the easiest thing to build a trend line, and you do it with the mouse.
 
tara:

Constructing a trendline is not the easiest thing to do, and you're using your mouse to do it.

Sorry, I probably didn't explain: I want to hotkey a simple trendline object (there are such objects: horizontal, vertical and trend line), which I would have already built myself. According to my strategy I need to build a lot of such lines. I have already prescribed a script to delete them myself)))
Reason: