[ARCHIVE]Any rookie question, so as not to clutter up the forum. Professionals, don't pass it by. Can't go anywhere without you - 5. - page 193

 
Diubakin:
If you do this, all the oddities should disappear.

To remove the "extra" condition, you can do this:

    int i, ot = OrdersTotal();
    double min = 1000.0;
    int min_ticket=0;
    for (i=ot - 1; i>= 0; i--)
    {
        if (!OrderSelect (i, SELECT_BY_POS)) continue;
        if (OrderType()!=OP_BUY) if (OrderType()!=OP_SELL) continue;
        if (min <= OrderLots()) continue;
        min = OrderLots();
        min_ticket=OrderTicket();
    }
 
artmedia70:

How so... Based on Igor Kim made something... Only one of your features... the rest are the same...

something like this, I guess:

And we call it:

to count Buy and count Sell on the current symbol, with Magic

Artyom, of course I start from Kim, removing unnecessary to me checks and adding necessary to me tasks. Not to reinvent the wheel! Thank you for the correction, I will be bolder to remove unnecessary! And I do not need to check the magician and the symbol, because sometimes I intervene "with my hands" and not before the multicurrency for me yet!
 
TarasBY:

To remove the "extra" condition, you can do the following



Igor, you're right. It's more readable that way...
 
borilunad:
Artyom, of course I come from Kim, removing unnecessary checks and adding the tasks I need. Not to reinvent a bicycle! Thank you for the correction, I will be bolder to remove unnecessary! And I do not need to check the magician and the symbol, as sometimes I intervene "manually" and not before the multicurrency for me yet!

You must check if (OrderMagicNumber()==0) ... This is a "manual" check.

If we want to interfere with other EAs working with another symbol, we can remove the check for OrderSymbol().

I've left the minimum necessary checks to work on a single character, with its own positions/orders. If you want to also touch what "handles", then you need to add a check for magic==0.

 
artmedia70:

Then you should do a check if (OrderMagicNumber()==0) ... is a check for "manual".

If we want to interfere with other EAs working with another symbol, we can remove the check on OrderSymbol().

I've left the minimum required checks for working on one symbol, with its own positions/orders. If you also want to touch that "by hand", then you need to add a check for magik==0.

I'm allowed to do that as it is! But I'll take note, especially with != and the continuum doesn't slow down at all! Thank you!
 
solnce600:

Thank you very much for your help.Everything is OK. But......

1. On some of the five minutes, more than 1 order opens.

2. Some orders are closed by stop orders whose price is different from the one prescribed in the code.


Well, come on, then everything is simple - make the same check in the closed orders) And about the closing price- sorry, it is set correctly, and then the server at what price really close it.
int start()

{

 double Price=iOpen (Symbol (),PERIOD_M5,0)+300*Point;        
 double SL=NormalizeDouble (Price-300*Point, Digits);         
 double TP=NormalizeDouble (Price+150*Point, Digits);    
 
 int last_order_bar = 0;
 int ot = OrdersTotal();

 if (ot>0) //если есть ордера в рынке
 {
   if (OrderSelect (ot-1,SELECT_BY_POS)) //выбрали последний ордер
      if (OrderType ()==OP_BUY || OrderType ()==OP_SELL) //проверили тип
         last_order_bar = iBarShift (Symbol (),PERIOD_M5,OrderOpenTime ()); //запомнили, на каком 5-минутном баре открыт последний ордер (если он есть)
 }
 
 int last_hist_order_bar = 0;
 int oht = OrdersHistoryTotal();

 if (oht>0) //если есть ордера в рынке
 {
   if (OrderSelect (oht-1,SELECT_BY_POS, MODE_HISTORY)) //выбрали последний закрытый ордер
      if (OrderType ()==OP_BUY || OrderType ()==OP_SELL) //проверили тип
         last_order_bar = iBarShift (Symbol (),PERIOD_M5,OrderOpenTime ()); //запомнили, на каком 5-минутном баре открыт последний закрытый ордер (если он есть)
 }
 
 if (ot==0 || last_order_bar>0) //если ордеров нет либо последний открыт не на текущем баре
    if (oht==0 || last_hist_order_bar>0) //если закрытых ордеров нет либо последний из закрытых был открыт не на текущем баре
       if (Bid>=Price)                       //если текущая цена доползла до цены открытия
          int Ticket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,SL,TP );

}
 
alsu:
Well, it's easy to do the same check in the closed orders) And about the closing price - sorry, it is set correctly, and then it's up to the server at what price it can be closed.

Thank you very much. Sorry for the inconvenience.
 
alsu:
And what about the closing price - sorry, it is set correctly, and then it is up to the server at what price it will really close.

Many thanks again for all your help. But.....

I opened only one order during the period of a year, i.e. the first order I came across.

And there are many more candlesticks with parameters to open an order in this period.

http://clip2net.com/s/2ToEo


I will not be able to close it. Thank you.

 
solnce600:

Many thanks again for all your help. But.....

I opened only one order during the period of a year, i.e. the first order I saw.

And there are many more candlesticks with parameters to open an order in this period.

http://clip2net.com/s/2ToEo


Thank you.


Correct my typo - the second time

 if (oht>0) //если есть ордера в рынке
 {
   if (OrderSelect (oht-1,SELECT_BY_POS, MODE_HISTORY)) //выбрали последний закрытый ордер
      if (OrderType ()==OP_BUY || OrderType ()==OP_SELL) //проверили тип
         last_order_bar = iBarShift (Symbol (),PERIOD_M5,OrderOpenTime ()); //запомнили, на каком 5-минутном баре открыт последний закрытый ордер (если он есть)
 }

I need

last_hist_order_bar = iBarShift (Symbol (),PERIOD_M5,OrderOpenTime ());
 
alsu:

Correct my typo - the second time

It's supposed to.


OK. Thank you very much.