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

 
Taras Slobodyanik:

Thank you!

If you don't mind my asking, could you please make the result function as a sum of pips for all open positions? I use a library for working with orders and I can't perform order operations without it :(

 

Greetings.

Can you tell me something?

OrderSend has

datetimeexpiration=0,// expiration date


How can I set the order to be deleted after it has been opened, for example, after 3 hours or 3 candles of the current chart?

 
Andrey Sokolov:

Greetings.

Can you tell me something?

OrderSend has

datetimeexpiration=0,// expiration date


How can I specify that the order is deleted after it has been opened, for example, after 3 hours or 3 candles of the current chart?


Period()*3*60

Period()- number of minutes in period

3 - number candlesticks you need

60-seconds in a minute

Then we add it to Time[0].

That's it.

 
Cпасиб
 
Alekseu Fedotov:


Period()*3*60

Period()- number of minutes in the period

3 - number candles you want

60-seconds in a minute

Add to Time[0] what you get.

That's it.

It has long been possible to write PeriodSeconds() with the required timeframe instead of Period()*60

In total, it looks as follows:

time_expiratonn=Time_set_order+PeriodSeconds(PERIOD_CURRENT)*number_of_words;

Or, instead of the current period, use the required number of candles of a given timeframe: PeriodSeconds(PERIOD_M15)*3 is the order lifetime of three fifteen-minute candles.

 
Andrey Sokolov:

Greetings.

Can you tell me something?

OrderSend has

datetimeexpiration=0,// expiration date


How can I specify that the order should be deleted after 3 hours or 3 candles of the current chart?

in general terms - no way. Because the limits are unknown. There is a minimum time, there is a maximum time, there are restrictions on order types. They are not communicated to the client, so you cannot use them.

Obviously, the action depends on the current mood of the particular DC. So control your own orders :-)

 
Artyom Trishkin:

It has long been possible to write PeriodSeconds() with the required timeframe instead of Period()*60

Total it turns out as follows:

time_expiratonn=Time_set_order+PeriodSeconds(PERIOD_CURRENT)*number_of_ candles;

Or, instead of the current period, we can use the number of candles of a given timeframe: PeriodSeconds(PERIOD_M15)*3 is the order lifetime of three fifteen-minute candles.


Thank you!
 

The topic has been discussed many times, but I'll ask for an explanation.


I decided to write an indicator, I made and ran it on m5, it even works and shows something.

My problems started when I decided to parallel install on m5 a ratchet from another TF

How to make it show data from different TFs in one window?

 

Hello ...


The OrderSelect() function copies the order data into the software environment ...When orders are selected sequentially using the SELECT_BY_POS parameter, the information is given in the order in which it was received from the trade server ...= I heard that orders can also be searched in reverse order, can you tell a "dummie" how to display this in MQL4 code ...

 
Yaroslav Nykula:

Hello ...


The OrderSelect() function copies the order data into the software environment ...When orders are selected sequentially using the SELECT_BY_POS parameter, the information is given in the order in which it was received from the trading server ...= I've heard that orders can also be searched in reverse order, would you tell a "dummy" how to display this in MQL4 code ...

Search by open

  for(int i=0; i<OrdersTotal(); i++) {
   if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {

Search inverse by closed

 for(int i=OrdersHistoryTotal()-1; i>=0; i--) {
  if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {