Questions from Beginners MQL5 MT5 MetaTrader 5 - page 883

 
Askr:
How does MT5 download the quote archive? In MT4 for example F2 and then you press refresh, but here?

You do not need to download anything to MetaTrader 5. You can use the quotes for the trading server you are connected to. If you want you can useCopyRates, if you want you can useCopyTicks.

 
Askr:
How does MT5 download the quotes archive? In MT4 e.g. F2 and then you press update, but here?

You can't do it directly. Unless you create a custom symbol for which you can import history. The custom symbol can only be used to work with the history. It will not allow you to trade by it.

 
Ihor Herasko:

What if the EA was not active at the time? After all, we would like to get the data from the account history. But this, unfortunately, cannot be done in an unambiguous way. It can only be done with a lot of reservations.

It is strange why the developers did not implementOrderCloseTime() in MT5. Apparently, there was a good reason for it).

 
lil_lil:

It's strange why developers didn't makeOrderCloseTime() in MT5. Apparently, there were serious reasons for that).

Because the order has a different meaning in terms of MT5 and Mql5. To find the closing time of a position, we need to select the orders and deals of this position, find among them a deal with the modifier DEAL_ENTRY_OUT and the time of this deal will be equal to the closing of the position.

 

Good afternoon, please advise, I cannot make a construction for the following condition: the indicator is started, suitable price parameters appear in the candle, a graphic indication is drawn, but let's say, if it is still far before the candle closes, the indicator can detect another candle combination in this place. The question is how to write the code in the process of every second monitoring so that it removes the previous result when the condition in this candle stops working?

Here is a proper example of rendering, but if I were to run the tester here, it would give me an incorrect candlestick reading. How do you fix it?

And another question - how to make an alert based on the following design concept:

Task - given: TF 1 hour.

The condition - to run the search part of the indicator only, say, after 55 minutes and up to 60 minutes of the current candle, and then restart the cycle.

How to implement this construct?

 
clickaider:

Good afternoon, please advise, I cannot make a construction for the following condition: the indicator is started, suitable price parameters appear in the candle, a graphic indication is drawn, but let's say, if it is still far before the candle closes, the indicator can detect another candle combination in this place. The question is how to write the code in the process of every second monitoring so that it removes the previous result when the condition in this candle stops working?

Here is a proper example of rendering, but if I were to run the tester here, it would give me an incorrect candlestick reading. How do I fix it?

1. The tester was and is working correctly, no errors.

2. mistake in your understanding of the testing process: when the first run of the indicator or paging history occurs (remember, the sign of this is prev_calculated==0), you go around all the bars in a loop. So, in this loop you use arrays-timeseries

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])

which, for each i-th member of the loop, has only ONE value Open, High, Low and Close.

But when all the bars are passed, the tester starts working in tick mode on each bar - that is why you can see how High goes up and Low goes down.

 
Vladimir Karputov:

1. the tester worked and works correctly, there are no errors.

2) There is an error in your understanding of the testing process: when the first indicator run or history paging occurs (remember, the sign of this is prev_calculated==0) you bypass all the bars in the loop. So, in this loop you use arrays-timeseries

which, for each i-th member of the loop, has only ONE value Open, High, Low and Close.

And when all bars are passed, the tester starts working on each bar in tick mode - that's why you can see how High goes up and Low goes down.

Yes, I agree that when the tester starts, the result is different due to price values filling, but the question is how to insert a condition when in one candlestick, for example, first one pattern is formed, but at the end another one appears but it cannot be replaced with another indicator entry because the corresponding condition is not prescribed. How to specify it?

if(Cmp(shadow_upper_1,shadow_lower_0)<0 && body_size_0 < body_size_1 && shadow_lower_0 >= 0.7*shadow_upper_0 && 8*body_size_0 >= shadow_lower_0 && 7*body_size_0 <= shadow_upper_0 && close_0 >= Upper1_0 && close_0 <= body_Upper_Upper1_mediane75_0 && Upper1_1 >= Upper1_2)
         if(InpEnablePAT_DOJIUP_UPPER1) DrawPattern(index,PATTERN_TYPE_DOJIUP_UPPER1,high,low,time);

Here is the code forming the candlestick indication, but how to make it re-drawable?

 
clickaider:

Yes, I agree that when you run the tester the result is different due to price values filling, but the question is how to put a condition in the construction, when in one candle, for example, first one pattern is formed, but at the end another pattern appears, but it cannot be replaced by another indicator entry, because the appropriate condition is not prescribed. How to specify it?

Here is the code forming the candlestick indication, but how to make it re-drawable?

Store the bar number in the index. Check it before drawing. If there is an object on the bar, delete it. ObjectDelete.

 
clickaider:

Yes, I agree that when you run the tester the result is different due to price values filling, but the question is how to put a condition in the construction, when in one candle, for example, first one pattern is formed, but at the end another pattern appears, but it cannot be replaced by another indicator entry, because the appropriate condition is not prescribed. How to specify it?

Here is the code forming the candlestick indication, but how to make it re-drawable?

Just to provide three states:

  • Draw pattern 1
  • Draw pattern 2
  • do not draw anything (for example, for DRAW_ARROW pass"0" into the indicator buffer, if you have written

//--- установим пустое значение 
   PlotIndexSetDouble(индекс_построения_DRAW_ARROW,PLOT_EMPTY_VALUE,0);
 
Vladimir Karputov:

Simply provide three states:

  • draw pattern 1
  • draw pattern 2
  • do not draw anything (for example, for DRAW_ARROW you pass"0" to the indicator buffer, if you have written

I sent you the source code, could you please see where to put it?
Files:
PatternsBB.ex5  81 kb