[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 664

 
Mathemat:

It wasn't me who cancelled it, it was the site's admins. I am only a forum moderator. I don't have access to the forum engine.

And the problem with Volfram wasn't the notifications or lack thereof, but the fact that he posted the same post several times in different threads (not counting the thread he created himself).

I don't mean you personally (I have no idea who is responsible for what on the forum at all).

In all the time (a long time ago and not so long ago) I've subscribed to probably a few dozen different threads, asked my questions there.

Today I don't have the faintest idea whether anyone has answered me "there" or not.

This thread is the only one I still follow, more or less. So it's possible that if I didn't get an answer

didn't get an answer on the other thread, I'll ask it here again. Probably others as well.

- What is the disabling of notifications related to? Are admins struggling with MT4 clients?

 
 extremumprice.mq4 
// Предназначен для использования в качестве примера в учебнике MQL4.
//--------------------------------------------------------------------
extern int Quant_Bars=30;                       // Количество баров
//--------------------------------------------------------------------
int start()                                     // Спец. функция start
  {
   int i;                                       // Номер бара 
   double Minimum=Bid,                          // Минимальная цена
          Maximum=Bid;                          // Максимальная цена
 
   for(i=0;i<=Quant_Bars-1;i++)                 // От нуля (!) до..
     {                                          // ..Quant_Bars-1 (!)
      if (Low[i]< Minimum)                      // Если < известного
         Minimum=Low[i];                        // то оно и будет мин
      if (High[i]> Maximum)                     // Если > известного
         Maximum=High[i];                       // то оно и будет макс
     }
   Alert("За последние ",Quant_Bars,            // Вывод на экран  
         " баров Min= ",Minimum," Max= ",Maximum);
   return;                                      // Выход из start()
  }
//--------------------------------------------------------------------

Hello. Can you please tell me where the error is: I put Ask > Maximum in the Buy criterion and Bid < Minimum in the Sell criterion. Only Buy is opened. If I am doing something wrong, how can I insert condition for the lowest and the highest price at a certain amount of bars? I'm guessing it's because Ask>Bid, but I'm not sure.

 
dimon74:
Yes. You have understood the task correctly. The only thing I want to point out is that in p.5, I want to set a new pending order based on the fact that I have just closed the position. Thank you!

So here is the logic:

1. set a pending order with a magic number, say 101, and reset the flag to convert the order into a position, say ConvOrd=false;

2. check if the position with a magic number 101 has appeared and if so set the conversion flag ConvOrd=true;

3. check ConvOrd=true and if ConvOrd==true,
check the existence of position with magic number 101 and if it is absent -
it means that it is already closed

{ reset ConvOrd=false; set a new one; }

I think we can do without flags.

 
eugggy:

Hello. Can you please tell me where the error is: I put Ask > Maximum in the Buy criterion and Bid < Minimum in the Sell criterion. Only Buy is opened. If I am doing something wrong, how can I insert condition for the lowest and the highest price at a certain amount of bars? I'm guessing it's because Ask>Bid, but I'm not sure.

Didn't think it through, but why are both Maximum and Minimum equal to Bid ? Where is Ask ?
 
artmedia70:
Didn't really think about it, but why are both Maximum and Minimum equal to Bid ? Where is Ask ?
I copied it from the tutorial; it was like that there, but not for opening orders. So, if I put in Ask, it will work, won't it?
 
eugggy:
Rewritten from the tutorial, it was like that there, just not for opening orders. So if Ask is inserted, will it work?
Show me your code, we are guessing by coffee grounds...
 
artmedia70:
No, it won't. You have the Maximum and Minimum variables assigned new Bid prices on each tick, and you need to find the maximum and minimum prices for a given time period, right?
Exactly right. Find and compare them to the current price. Conventionally speaking, if the price is higher than the local maximum - buy, below the minimum - sell.
 
eugggy:
Absolutely right. Find and compare them to the current price. Conventionally speaking, if the price is above the local high, buy, below the low, sell.
Yes, I've already looked into the code, I was looking diagonally... :))
Already corrected my answer - asked to post the code...
 
artmedia70:
Show me your code, it's a guessing game...
double
Min=Bid, variable declaration

Max=Bid,

____________________________________________________________________________________________

for (i=0;i<=20-1;i++) opening criteria

{
if (Low[i]<Min) Min=Low[i]:
if (High[i]>Max) Max=High[i];

}

if (................. &&Ask>Max)

{

Opn_B=true; //open Buy

}

if (................ &&Bid<Min)

{

Opn_S=true; //open Sell

}

___________________________________________________________________________________________

I'm sorry it's so ugly - I had to write it from memory as the code didn't work and I deleted it. But you, as a professional, should be understandable (I hope).

____________________________________________________________________________________________

 
Count highs and lows not from the zero bar but from the first bar, on the zero bar the Bid cannot be less than the Min.