[Archive!] Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Couldn't go anywhere without you - 2. - page 281

 
Pyro:

tara


It's interesting, because the order setting price in my code is normalized to 4 digits, i.e. fractions of a pip cannot be there. Why is it so? And yes, it works properly now! THX

Actually, normalisation has to be done at the moment of calculation:

   int dg=MarketInfo(Symbol(),MODE_DIGITS);        // Количество цифр после десятичного точки в цене инструмента
   if (NormalizeDouble(OrderOpenPrice()-(p1+more),dg)==0) {
      // ... тут код, если результатом сравнения стал ноль, т.е. сравниваемые величины равны
      }

and some points in your code:

for(int i=1 ; i <= OrdersTotal() ; i++)   // делаете цикл от второго ордера в списке. Почему бы сразу не for(int i=0; i<OrdersTotal(); i++) ?
   {
   if(OrderSelect(i-1,SELECT_BY_POS,MODE_TRADES))  // если выбрали ЛЮБОЙ ордер, пусть он даже открыт другим советником или вручную
      {                                           
      if(OrderOpenPrice()-(p1+more) == 0)          // сравниваете без нормализации
         {
         ordersethigh1=true;                       // желательно флагу ПЕРЕД циклом задать значение false
         break;
         }
      }
   }
     
if((ordersethigh1==false) && (p2-price>pointsclose))  // второе условие тоже не нормализовано
   {
   OrderSend(Symbol(),OP_SELLLIMIT,baselot,p1+more,3,NULL,NULL,"Comment",0001,0,White);
   }
 

artmedia70


Well, I wrote based on your code. Simplified for now (I'm figuring it out). The only thing that became clear is that everything needs to be normalized. It's kind of a revelation (everything worked on the tester). I'm working it out now.

если выбрали ЛЮБОЙ ордер, пусть он даже открыт другим советником или вручную

In this case, we don't need redundant code. But I added a check for the tool.

I've got two variants, both of them work:

if(OrderOpenPrice()-(channelhigh+more) <=Point*0.5)

if(NormalizeDouble(OrderOpenPrice()-(channelhigh+more),4) == 0)

Thank you, it cleared up a lot!



 
Pyro:

artmedia70


Well, I wrote based on your code. Simplified for now (I'm figuring it out). The only thing that became clear is that everything needs to be normalized. It's kind of a revelation (everything worked on the tester). I'm working it out now.

Excessive code is not necessary in this case. But I added a check for the tool.

I got two variants, both working:


Thanks, a lot has been cleared up!

Is it redundant to check what type the selected order is? If it is a Buy or Sell order? Without checking, your function will tell you that there is a pending order (you are checking for its presence). You want to check whether there is a pending order, and you will get true if there is any type. Even if you open it manually. There are four types of pending orders. In order to avoid confusion, it is recommended to pass in a function, when you call it, the type of a pending order, and then check if the order type you have chosen matches the one passed into the function.
(This check is not present in my example on p. 277). It simply checks for any pending - if the type is less than 1 and greater than 5, we will go on to select the next one).

Next. Your EA can work on one TF, and on the other one, another EA can work simultaneously. Both of them are working on the same instrument. A position opened by another EA will be considered by this EA as "yes, there is an order". So, we need to introduce a MagicNumber check so that the Expert Advisor can distinguish its own orders and positions.

Therefore, the checks for the symbol of the trade instrument, magic number and type of the order being checked are not excessive, but necessary. This is the minimum, but not redundancy.

 

Greetings comrades!

Please advise: Has anyone encountered the problem of searching for the last closed order. Has it become profitable or unprofitable?

What methods have you used?

Thank you in advance.

R.S. I guess that the operation is not difficult, but I do not know how to get closer to it.

 
artmedia70:

Therefore, the checks for the symbol of a symbol, magic number and type of an order being checked are not excessive, they are necessary. This is the minimum but not excessive.

My mistake here was that I only posted one function in essence. There will be checks, of course. It's just that this piece of code, it's a training piece in many ways, is nothing more than part of the EA. Thanks again for your help, friends!

 
ramirez17:
I'm guessing it's a simple operation, but I don't know how to go about it.
You'd be surprised how popular this question is.
Google query:
last closed order site:mql4.com
 
ramirez17:

Greetings comrades!

Please advise: Has anyone encountered the problem of searching for the last closed order. Has it become profitable or unprofitable?

What methods have you used?

Thank you in advance.

s.s. I guess this operation is not too complicated, but I don't know how to approach it.

https://www.mql5.com/ru/forum/131859/page4#434229

https://www.mql5.com/ru/forum/131859/page4#434230

 
granit77:
You'd be surprised how popular this question is.
Google query:
last closed order site:mql4.com

Ok. I forgot about google. Went straight here :)
 
in which folder should I put the set file from the EA?
 
drm1:
in which folder should I put the set file from the EA?
expert/presets
Reason: