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

 
How can I programmatically check whether the one-click trading panel is running or not?
 
Vladimir Tkach:
How can I programmatically check if the one-click trading panel is running or not?

Pulled it out of the class:

   //--- Получение параметра "панель торговли OneClick" на чарте
   bool                 IsChartOneClick(void)            {return(ChartGetInteger(m_chart_id,CHART_SHOW_ONE_CLICK));}
 
Artyom Trishkin:

Such a problem should be solved by checking whether there is, or has been, an open and closed position on this very bar.

Otherwise you will pile everything up. The signal function should send signals and the trading function should check the validity of the signal.


That's what I wanted to do, but I don't know how to implement it. How to check on the current bar.
 
AlGuru:

This is what I wanted to do, just don't know how to implement it. How to check on the current bar.

Check if there is an open position which was opened on bar 0.

If not, then additionally check if there is a closed position, which was opened on bar 0 and closed on the same bar.

Accordingly, you need to make these functions:

  1. Open bar of last open position
  2. last closed position open bar
  3. Close bar of last closed position
  4. The fact of opening and closing the last closed position on the same bar (the previous two functions 2 and 3 are used)
Then, using these functions, get the data you need to make a decision.
 
a196012a:

Good day to all!

Please advise how to code the following action in the strategy tester

General idea

1.open order N -X (volume = 0.1)

2.If this order is closed on SL, then. to compensate for the loss, immediately at the closing price on SL of an order N X, open the order N - X1 (volume = 0.3)

WE HAVE TO DO.

3 If the order (volume = 0.3) is closed on SL, only the value of the hour of opening of the order N - X will be remembered to compensate for losses at which it was opened.

I know how to open both orders, but I cannot find my way to the end, how to memorize the hour value for an order with 0.1 lot volume that was closed on the SL.

NOTE: This is related to order closures on the same tick.

Sometimes more than one order with the volume of 0.1 and 0.3 are closed on one tick.

If 3 orders of 0.1, for example, are closed on a single tick on a SL, instead of opening 3 orders of 0.3. - only 1 order of 0.3 lots is opened

In this case if I close only 1 order of 0.3 lots on the SL, I will not get values of the hour when two orders of 0.1 lot are opened which compensate their losses.

I.e., I need 3 orders of 0.3 lots to be opened in this case, not one.


Sometimes 3 orders of 0.3 lots will be closed by a SL on one tick, despite the fact that their corresponding 0.1 lot orders were opened on different ticks (but just at one price).

In this case the program saves the right value only for one last order of 0.1 lot.

I need the program to save the hour value of each order (0.1 lot) closed by SSL.


Here is my code, which we need to modify.

Thank you for your help.

Here is an example of a situation where several orders are closed on one tick


Good day!

Why do you need to consider the time of each closed order? You can do without it... Or do you have this data somewhere else?

2) And exactly 3 last orders that closed at a loss? Or it does not matter how many orders there are, maybe 5 or 8... And accordingly, for each

...an order which closed with a loss should correspond to an order with a bigger lot?

 
Valerius:


Good day!

1. why do you need to time every bar that is closed? You can do without it... Do you keep this data somewhere else?

2) And what about the last 3 orders that closed with a loss? Or it does not matter how many orders there are, may be 5 or 8... And accordingly, for each

...an order which closed with a loss should correspond to an order with a larger lot?

Thanks for your reply.

Yes, I take into account the opening hour in the next steps of the program.

The number can be from 2 to 10.

Exactly every order which was closed by a stop loss should correspond to another order which opened with a bigger volume.

By "match" I mean if within 1 day 3 orders opened at any time were closed by the SL, immediately at their closing price

3 orders of a larger volume should open. Right after each individual order is closed. For example, at 12 o'clock an order closed at the price of 1.2000

At 12 o'clock at the price of 1.2000 a larger order is opened. This is the same for every order of a smaller volume which is closed by a SL. After the order of a larger volume is closed by a SL, remember the hour when the order opens in reply to the close of which it was opened. That is, if the order was opened at 12:00 at the price of 1.200 and closed through a stop, then the high-volume order opens at 12:00 at the price of 1.2000. If the order of larger volume was closed by a SL , remember the opening hour of the order of smaller volume, i.e. 12 o'clock.

We should remember the same after each high-volume order which was closed only through the SL.

I find it especially difficult to open orders and save the hour values when several orders (from 2 to 10) are closed by a single tick on a SL.

See the detailed description of this situation in the initial post.

 
a196012a:

Thank you for your feedback.

Yes , the opening hour I take into account in the subsequent program actions.

The number can be from 2 to 10.

Exactly every order closed by a stop should correspond to another order opened by a bigger volume.

By "match" I mean if within 1 day 3 orders opened at any time were closed by the SL, immediately at their closing price

3 orders of a larger volume should open. Right after each individual order is closed. For example, at 12 o'clock an order closed at the price of 1.2000

At 12 o'clock immediately at the price of 1.2000 a larger order is opened. This is the way it is done in every order. And after the order of a larger volume is closed by a SL, we should memorize the hour of its opening in response to the close of which it was opened. That is, if the order was opened at 12:00 at the price of 1.200 and closed through a stop, then the high-volume order opens at 12:00 at the price of 1.2000. If the order of larger volume was closed by a SL , remember the opening hour of the order of smaller volume, i.e. 12 o'clock.

And so after each order of larger volume which was closed only on SL.


And one more detail.... For example, the 1st order was closed with 0.1 lot, the 2nd order was opened with 0.3 lot. We have remembered the time of opening of the first order. Then the 2nd order was closed by a stop and we memorized the time of the 2nd order opening and set an order with 0.9 lot. And so on. Have I understood correctly? Should we always remember the time of the first order only?
 
Hello. Why do theeuro vs usdcurrency pairs show149.16325 instead of 1.0616?


 
sidovi:
Hello. Why is theeuro vs usd pair displayedat 149.16325 instead of 1.0616?



Try to update the quotes. Service - Quote Archive - Select your currency pair - Load.

If that doesn't help, reinstall the metatrader.

 
Valerius:

Well and one more clarification.... For example, 1st order was closed with 0.1 lot, 2nd order was opened with 0.3 lot. We have remembered the time of opening of the first order. Then the 2nd order was closed by a stop and we memorized the time of the 2nd order opening and placed the order with 0.9 lot. And so on. Have I understood correctly? We only need to remember the time of the first order?

All larger orders will only open with a volume of 0.3 lots. All orders of a smaller volume which are opened in response to a close on the SL in the volume of 0.3 lots will open in the volume of 0.1 lot. Only 0.1 and 0.3. There are no other volumes.

While closing a 0.3 lot order through the SL, please remember the hour when the order was opened in reply to the closing of which it was opened (i.e. 0.1 lot order).

Thank you for your help.

Can you please tell me where the option is set to send a message to my email when there is a reply to my post.

Thank you very much again.