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

 

Good day, everyone !

I have looked through all EA pages, looked at codes of EAs based on pending orders,

I have not found any answer, searching through all pages of the Forum, and re-reading MQL tutorial and documentation.

Perhaps, I did not look carefully. I decided to ask it here.

I am writing an EA based on pending orders. I had no problems with criteria of position opening based on indicator data (<, >, =, etc.).

But, currently, the system is not based on any indicator. The criterion for position opening is the PRICE.

Namely, at Bid equal to the PRICE level, let's assume, ХХХ.00 or ХХХ.50 (for the Yen pairs), the block of criteria says that

there is a criterion to buy (or sell) and sends it to the order opening block.

An approximate example is shown in Fig. 1 when the level is fixed and set, for example, by a user.

int start()                                   // Спец. функция start
  {
//----
   double
   Level,                                     // Сигнальный уровень
   Price;                                     // Текущая цена
   Level=140.00;                              // Задаём уровень
   Price=Bid;                                 // Запрашиваем цену
//----
    if (Price==Level)                          // Оператор if с условием
     {
      Alert("Курс равен  заданному уровеню");  // Сообщение трейдеру
     }

   return;// Выход из start()
  }

The question is how to write the condition to compare the current BID with the levels that were not set beforehand but are flat,

for example 140.00, 141.00, 142.00 .... namely with XXX.00

The first part of the condition is clear, e.g.

if (NormalizeDouble(Price,Digits) >= NormalizeDouble(Level,Digits))

The second part with Level, what to do.

I thank you in advance,

Respectfully,


P.S. If this has already been discussed and I've missed it, poke me, please.

 
Melko:

II This is an elementary function of placing pending orders, the parameters are not important, but it is important to make the Expert Advisor (it can use the existing loop of order evaluation) after receiving a "new price" or to go through it, or to somehow avoid placing orders at the same price. In this case, the order placing cycle should not stop. Please, help me.

Delete all of your spools and learn how to insert code by pressing the SRC button before placing orders!
 
Shum_sp:

Good day, all !

I have looked through all the EA pages, looked at codes of EAs based on pending orders,

I have not found any answer, so I have searched all pages of the Forum, read MQL tutorial and Documentation again.

I may have looked at it badly. Decided to ask here.

I am writing an EA based on pending orders. Previously, there was no problem with the criterion of opening a position based on indicator data (<, >, =, etc.).

But, at the moment, the system is unsyndicatorial. The criterion for opening a position is the PRICE.

Namely, at Bid equal to the PRICE level, say, ХХХ.00 or ХХХ.50 (for yen pairs), the block of criteria says that

there is a criterion to buy (or sell) and it sends us to the order opening block.

An approximate example is shown in Fig. 1, when the level is fixed and set, for example, by the user.

The question is how to specify the condition that would allow comparing the current BID with predefined but equal levels,

e.g. 140.00, 141.00, 142.00 .... namely from XXX.00

The first part of the condition is clear, e.g.

In the second part with Level, what to do.

I thank you all in advance,

Respectfully,


P.S. If this has already been discussed and I missed it, poke me please.


if (NormalizeDouble(Price,Digits) >= NormalizeDouble(Bid,0)) //Для 4-х знаков можно и 1 или 2 вместо 0.
 
evillive:


Too much, I think.

Are you going to answer that?

 
tara:


Too much, I think.

Are you going to answer that?


What's the question, as they say, is the answer. Who knows how the price is calculated, and the level is not specified in advance...


But if price = Bid, then...

if (Bid >= NormalizeDouble(Bid,0)) //опять же можно и 1 или 2 вместо 0.
 
Shum_sp:

Good day, all !

I have looked through all the EA pages, looked at codes of EAs based on pending orders,

I have not found any answer, so I have searched all pages of the Forum, read MQL tutorial and Documentation again.

I may have looked at it badly. Decided to ask here.

I am writing an EA based on pending orders. Previously, there was no problem with the criterion of opening a position based on indicator data (<, >, =, etc.).

But, at the moment, the system is unsyndicatorial. The criterion for opening a position is the PRICE.

Namely, at Bid equal to the PRICE level, say, ХХХ.00 or ХХХ.50 (for yen pairs), the block of criteria says that

there is a criterion to buy (or sell) and it sends us to the order opening block.

An approximate example is shown in Fig. 1, when the level is fixed and set, for example, by the user.

The question is how to specify the condition that would allow comparing the current BID with predefined but equal levels,

e.g. 140.00, 141.00, 142.00 .... namely from XXX.00

The first part of the condition is clear, e.g.

In the second part with Level, what to do.

I thank you all in advance,

Respectfully,


P.S. If this has already been discussed and I missed it, poke me please.


With this scheme, you can simply compare variables, including for equality.
 
Shum_sp:

The question is how to write a condition to compare the current BID with non-pre-set but level levels,

for example 140.00, 141.00, 142.00 .... namely with XXX.00



int Level=140;                              // Задаём уровень
 
:)
 
artmedia70:


Good afternoon!


I mean, it's a lot to prescribe all the levels.

The Expert Advisor should determine that the level is XXX.00, the user should not participate in this and specify the levels at which to work.

I cannot understand how to explain it that the current price is XXX.00

Thank you all.

 
evillive:

What the question is, as they say, is the answer. Who knows how the price is counted, and there's no pre-specified level...


But if price = Bid, then.


Yes, in the example, price = Bid. That's what I'm comparing. Instead of "level", something is needed. I will try this variant.


Only 1 and 2 instead of 0, will give the first or both digits after the tokens, it will no longer be XXX.00. With zero we have to try.

? If the level is not 00, for example, it needs XXX.15 or XXX.35, how can it be compared?

The function

NormalizeDouble(Bid,0))

cuts the value to a numeric value or to Digits, while it needs to select the number after the decimal point and work with it, no matter what the integer part is.

Thank you.

Reason: