Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1209

 
How to deposit
Via app
To the trader's account!
 
leonerd:
How can I get a closed position comment in OnTradeTransaction?

Interesting question. To better understand it I manually opened a position and specified comment'123456' - then closed the position and ran theHistory Deals and Orders script. And now notice that the comment is present only at the order (trade order) on the basis of which there was a transaction that led to the position and at the transaction that occurred as a result of the execution of the order):

Deal:
|Ticket              |Order               |Time                |Time msc            |Type                |Entry               |Magic               |Reason              |Position ID        
|566077885           |587994287           |2020.04.30 19:54:32 |1588276472801       |DEAL_TYPE_BUY       |DEAL_ENTRY_IN       |0                   |DEAL_REASON_CLIENT  |587994287          
|Volume              |Price               |Commission          |Swap                |Profit              |Symbol              |Comment                                  |External ID        
|0.01                |0.96703             |0.00                |0.00                |0.00                |USDCHF              |123456                                   |                   
Order:
|Ticket              |Time setup          |Type                |State               |Time expiration     |Time done           |Time setup msc      |Time done msc       |Type filling       
|587994287           |2020.04.30 19:54:32 |ORDER_TYPE_BUY      |ORDER_STATE_FILLED  |1970.01.01 00:00:00 |2020.04.30 19:54:32 |1588276472800       |1588276472801       |ORDER_FILLING_FOK  
|Type time           |Magic               |Reason              |Position id         |Position by id     
|1970.01.01 00:00:00 |0                   |ORDER_REASON_CLIENT |587994287           |0                  
|Volume initial      |Volume current      |Open price          |sl                  |tp                  |Price current       |Price stoplimit    
|0.01                |0.00                |0.96703             |0.00000             |0.00000             |0.96703             |0.00000            
|Symbol              |Comment                                  |External id        
|USDCHF              |123456                                   |                   
        
Deal:
|Ticket              |Order               |Time                |Time msc            |Type                |Entry               |Magic               |Reason              |Position ID        
|566078174           |587994568           |2020.04.30 19:54:45 |1588276485331       |DEAL_TYPE_SELL      |DEAL_ENTRY_OUT      |0                   |DEAL_REASON_CLIENT  |587994287          
|Volume              |Price               |Commission          |Swap                |Profit              |Symbol              |Comment                                  |External ID        
|0.01                |0.96700             |0.00                |0.00                |-0.03               |USDCHF              |                                         |                   
Order:
|Ticket              |Time setup          |Type                |State               |Time expiration     |Time done           |Time setup msc      |Time done msc       |Type filling       
|587994568           |2020.04.30 19:54:45 |ORDER_TYPE_SELL     |ORDER_STATE_FILLED  |1970.01.01 00:00:00 |2020.04.30 19:54:45 |1588276485330       |1588276485331       |ORDER_FILLING_FOK  
|Type time           |Magic               |Reason              |Position id         |Position by id     
|1970.01.01 00:00:00 |0                   |ORDER_REASON_CLIENT |587994287           |0                  
|Volume initial      |Volume current      |Open price          |sl                  |tp                  |Price current       |Price stoplimit    
|0.01                |0.00                |0.96700             |0.00000             |0.00000             |0.96700             |0.00000            
|Symbol              |Comment                                  |External id        
|USDCHF              |                                         |                   
        


It means that when closing a position (in OnTradeTransaction the transaction type is TRADE_TRANSACTION_DEAL_ADD) we have to select all orders related to this position from the trading history and find the order that caused this position to appear.

History Deals and Orders
History Deals and Orders
  • www.mql5.com
Скрипт "History Deals and Orders" выводит абсолютно все свойства для сделок и ордеров из торговой истории в заданном временном интервале. Доступен вывод как во вкладку "Эксперты" терминала, так и в текстовой файл (текстовой файл располагается в папке [data folder]\MQL5\Files). Если вывод осуществляется в текстовый...
 
DotCom:
Good afternoon. How to draw a trend line on two extrema without drawing a trend line object on a chart using mql5 tools and monitor its breakthrough without drawing the line itself on the chart. Is it possible, maybe there is a way?
An Expert Advisor shall draw trend lines on 50-70 pairs at once and it would be better if windows of these charts were closed, so that a breakout of trend lines would be calculated without open charts.

Use the straight line equation:

//+------------------------------------------------------------------+
//| Уравнение прямой                                                 |
//+------------------------------------------------------------------+
double EquationDirect(const int left_bar,const double left_price,const int right_bar,const double right_price,const int bar_to_search) 
  {
   return(right_bar==left_bar ? left_price : (right_price-left_price)/(right_bar-left_bar)*(bar_to_search-left_bar)+left_price);
  }
//+------------------------------------------------------------------+

Specify the bar number and price of the point on the left, specify the bar number and price of the point on the right (a virtual line is plotted on these points) and specify the bar you are looking for.
The function will return the price of the bar you are looking for.

 
Artyom Trishkin:

Use the straight line equation:

Specify the bar number and price of the point on the left, specify the bar number and price of the point on the right (a virtual line is plotted on these points) and specify the bar you are looking for.
The function will return the price of the bar you are looking for.

Thanks, I'll give it a try.

 
Hello,
Can you tell me how to calculate the parameters for the daily parabolic (and four-hour parabolic ) to put ( visualise) them
on an hour timeframe?
 

How can I smooth out the line graph, at the level of the peaks (exactly the graph displayed on the main chart)?

iMA does not work, there is no smoothing, (maybe the Curve function?)

Files:
1588528157.png  22 kb
 

Trying to work with the built-in calendar. What is sus? Why is the data different, for example comparing with investing.com.

Here's a download of the embedded news (server time GMT+2) to the file:

2018.01.11 15:30        EUR     ECB Monetary Policy Meeting Accounts    CALENDAR_IMPORTANCE_MODERATE
2018.01.11 16:30        USD     PPI m/m CALENDAR_IMPORTANCE_MODERATE
2018.01.11 16:30        USD     Core PPI m/m    CALENDAR_IMPORTANCE_LOW
2018.01.11 16:30        USD     PPI y/y CALENDAR_IMPORTANCE_LOW
2018.01.11 16:30        USD     Core PPI y/y    CALENDAR_IMPORTANCE_LOW
2018.01.11 16:30        CAD     New Housing Price Index m/m     CALENDAR_IMPORTANCE_MODERATE
2018.01.11 16:30        USD     Continuing Jobless Claims       CALENDAR_IMPORTANCE_LOW
2018.01.11 16:30        USD     Initial Jobless Claims  CALENDAR_IMPORTANCE_MODERATE
2018.01.11 16:30        USD     Initial Jobless Claims 4-Week Average   CALENDAR_IMPORTANCE_LOW
2018.01.11 17:00        MXN     Industrial Production n.s.a. y/y        CALENDAR_IMPORTANCE_LOW
2018.01.11 17:00        MXN     Consumer Confidence Index       CALENDAR_IMPORTANCE_LOW
2018.01.11 17:00        MXN     Consumer Confidence Index n.s.a.        CALENDAR_IMPORTANCE_LOW

And here is a screenshot from investing.com for the same date:


Importance difference. The important news on investing.com may be Moderate in MQL5 calendar.

I attribute the time difference of an hour (also requested from GMT+2 on investing.com) to the DST transition.

 

Hello.

Can someone tell me how to redraw the indicator from OnChartEvent() function? In this function I change the indicator buffer value, but it won't change on the chart. ChartRedraw() does not help.

The indicator changes on the chart only when running OnCalculate(). Is there any way to redraw it without starting OnCalculate()? Or how to force start OnCalculate()?

 
MQL_User:

Hello.

Can someone tell me how to redraw the indicator from OnChartEvent() function? In this function I change the indicator buffer value, but it won't change on the chart. ChartRedraw() does not help.

The indicator changes on the chart only when running OnCalculate(). Is there any way to redraw it without starting OnCalculate()? Or how to force start OnCalculate()?

interesting question, i wanted to redraw the indicator in this event a long time ago, to see how they would look on a chart

I still have to use this event in the multi-currency, I guess the developers have postponed the normal multi-mode until MQL6

---

another question. As always, the developers have given a lot to think about

the same indicator can be built in two ways:

1 plot and 1 coloured buffer, or the same indicator with 2 plot buffers - one up with its own colour and another down also with its own colour, it's a variant without colour buffer.

Which one will be faster or more correct? I would like an expert answer

---

it would seem that you can look with 1 plot + 1 colour buffer 0 - up trend and 1 - down trend, and if you need value, you can take it from the plot. everything is separate and understandable, but

the second variant has 2 plot buffers - the first has EMPTY_VALUE and the second the value and the trend (colour)

---

MQL4 completely missed it, if the second option is just his legacy, are there any obvious advantages to using the 1-method? (i.e. throw out the second option at once)

asked two good experts a question, they could not answer.

 
Fast235:

Interesting question, I wanted to redraw the indicator in this event a long time ago, to see how they would look similar on the chart

I still have to use this event in the multi-currency mode, the developers seem to have postponed the multi-mode until MQL6

---

another question. As always, the developers have given a lot to think about

the same indicator can be built in two ways:

1 plot and 1 coloured buffer, or the same indicator with 2 plot buffers - one up with its own colour and another down also with its own colour, it's a variant without colour buffer.

Which one will be faster or more correct? I would like an expert answer

---

it would seem that you can use 1 plot + 1 colour buffer to look at 0 - up trend and 1 - down trend, and if you need value, you can use plot. everything is separate and understandable, but

the second variant has 2 plot buffers - the first has EMPTY_VALUE and the second the value and the trend (colour)

---

MQL4 completely missed it, if the second option is just his legacy, are there any obvious advantages to using the 1-method? (i.e. throw out the second option immediately)

Asked the question to two good experts, couldn't answer.

Didn't think I'd run into such a problem, as at first glance it should be self-evident to redraw the graph from the program. In this light, the purpose of the ChartRedraw() function is unclear...