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

 
tara:

Well, that would be a particularly elegant perversion. I don't think so.

Yeah, I've already checked, I think... if it wasn't, you could keep a sell autsraeli in an Islamic account, and a buy in a spread account. There would be stable profits... more than in the bank
 

1. Situation of partial closing of an order - the ticket is changed, and written in the comment to the new order, it is clear, it can be taken out.
2. The situation of some brokers when transferring a position through the night/weekends, they close the position and open it again at the beginning of the day, how does the ticket behave in this case? The old ticket is written in the comment of the new position, nothing happens? What are the ways to keep track of orders if there are more than 4-8 of them?

 
Vladislav: you should have deleted the post, imho.
 
artmedia70:


datetime is the same as int



Got me thinking - I was sure datetime was an unsigned int, I checked and you were right. It turns out that MT4 will not live longer than 2038 ;). There is still time )))))))))))))))))))))))).
 
tara:
Vladislav: you should not have deleted the post, imho.


No not for nothing, IMHO, of course: datetime is really int. Although, everything written is correct in general, but not in this case. Here I can't understand the logic of ICL developers (((((((((((((. Maybe they will correct it in a new version of the language.

HH the meaning of the deleted post was that types should be used as intended, otherwise you can run into runtime errors. In this case for date it is better datetime, not int, because there is a hope that the mismatch of types will be corrected.

 
VladislavVG:


No for nothing, IMHO, of course: datetime is really int. Although, everything that has been written is correct in general, but not in this case. I can't understand the logic of ICL developers here (((((((((((((. Maybe they will correct it in a new version of the language.

HH the meaning of the deleted post was that the types should be used as intended, otherwise you can run into run-time errors. In this case, for date it is better datetime, but not int, because there is hope that the mismatch of types will be corrected.


I agree, we should not use int instead of datetime, or color. not even because of execution errors, but from what will happen when the developers put things in order.
 
VladislavVG:


No for nothing, IMHO, of course: datetime is really int. Although, everything that has been written is correct in general, but not in this case. I can't understand the logic of ICL developers here (((((((((((((. Maybe they will correct it in a new version of the language.

HH the meaning of the deleted post was that types should be used as intended, otherwise you can run into runtime errors. In this case, for date it is better datetime, but not int, because there is hope that the mismatch of types will be corrected.

Yes. They promised 8 bytes as in MQL5. I guess it will be the __time64_t (UNIXTIME64) type.
 
solnce600:

Gentlemen professionals.... I am confused

TarasBY andartmedia70 say that my error is related to the value of the variable storing the magic number of the order


Vinin saysit's not about magic number but about wrong logic......... artmedia70 argues with him

.

If professionals do not have a consensus on my problem, what should I do as a beginner to solve my problem ?


The mistake with the magician causes your EA not to see that its position is closed on a stop when closing on a stop. Why? The answer is that you open a position with magic 123 and send the variable Magic to the function that checks for closing the position at the stop. What do you think it equals when initialized implicitly? Zero. The function is naturally searching for positions with magic number 0 and it is equal to 123 in your positions. And we're not arguing, just... ...reasoning... Check the response to close on the stop:


double   Lot;
int      Magic=123;

int start() {

   double Price=iOpen(Symbol (),0,0);
          
   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(),0,OrderOpenTime()); 
      }                                    

   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_hist_order_bar=iBarShift(Symbol(),0,OrderOpenTime());
      }

   if (ot==0)
      if (Bid==Price)
  //=============================================================== 
         if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
            if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
               if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))
  //============================================================
                  Lot=MarketInfo(Symbol(), MODE_MINLOT);   
                  if (isCloseLastPosByStop(Symbol(), OP_BUY, Magic, Lot)) {
                     Lot=Lot*2;
                     OrderSend(Symbol(),OP_SELL,Lot,Bid,1,Ask+1500*Point,Ask-300*Point,"jfh",123 );
                     }
                  else {
                     Lot=0.1;        
                     OrderSend(Symbol(),OP_SELL,1,Bid,Lot,Ask+1500*Point,Ask-300*Point,"jfh",123 );
                     }
   return(0);
}
//+----------------------------------------------------------------------------+
bool isCloseLastPosByStop(string sy, int op, int mn, double &ll) {
   double   pt;
   int      dg, i, j=-1, k=OrdersHistoryTotal()-1;
   datetime t=0;                                   // во избежание возможных ошибок после возможных будущих улучшений
   for (i=k; i>=0; i--) {
     if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
         if (OrderMagicNumber()!=mn)   continue;   // если магик не тот, переходим к следующему
         if (OrderSymbol()!=sy)        continue;   // если символ не тот, переходим к следующему
         if (OrderType()!=op)          continue;   // если тип не тот, переходим к следующему
         if (t<OrderCloseTime()) {
            t=OrderCloseTime();
            j=i;
            }
         }
      }
   if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
      dg=MarketInfo(OrderSymbol(), MODE_DIGITS);      // количество знаков в цене символа ордера
      pt=MarketInfo(OrderSymbol(), MODE_POINT);       // размер пункта инструмента в валюте котировки ордера
      if (MathAbs(OrderClosePrice()-OrderStopLoss())<0.5*pt) { // Если закрыт по стопу
         ll=OrderLots();                              // записываем количество лотов в ордере, закрытом по стопу
         return(true);                                // возвращаем истину
         }
      }
   return(False);                                     // возвращаем ложь (позиции нету, либо не по стопу)
}
//+----------------------------------------------------------------------------+

I didn't look at the rest of your "dead" EA logic - I was helping you figure out the function to check closing on stop...

 
tara:

You're welcome. Good luck!

Alexei! Good afternoon!

Our communication doesn't get out of my head...... and here's why.....

In relation to my coding I have repeatedly heard comments about the lack of logic.

Yesterday you explained Boolean algebra to me, it is a wide and deep subject.

The fact is that I am not a mathematician and certainly not an algebraic mind.

Some not very difficult mathematical things I understand.... but not at once, and complex things my brain does not perceive at all.

Over six months ago, before I started studying the MCL programming textbook, I was wondering

whether I could understand it without mathematical ability.

But Mr. Kozlov, in the preface to his textbook, said that it's actually much simpler than it looks at first glance.

at first glance.

And indeed 60-70% of his tutorial I think I'm now able to understand (probably not the first time) and as a result I can already code something.

Until yesterday it seemed to me that all the complex mathematical calculations (which I can not understand) do the program, and I only need to know the rules by which

the program works and does the calculations.

But our conversation yesterday led me to the idea that if I do not learn Boolean algebra, my codes will be absent logic.

If my codes will lack boolean logic, my programs will not work correctly, or will not work at all.

But I glanced at Wikipedia yesterday and realized - Boolean algebra and probably logic - is not for my mind!

Yesterday you have quickly deduced from a cursory glance at a fragment of my code that it lacks Boolean logic.

If you don't mind, could you please explain a course of your reasoning, which preceded your conclusion about absence of logic in this fragment.

If I understand it, I will move on. If I don't understand..... I will probably conclude that programming is something that greatly exceeds my abilities.

Thank you.

if (ot==0)
if (Bid==Price)
if(((Open[1]-Close[1])>100*Point)&&((Open[1]-Close[1])<120*Point))
if(((High[1]-Open[1])>40*Point)&&((High[1]-Open[1])<60*Point))
if(((Close[1]-Low[1])>40*Point)&&((Close[1]-Low[1])<60*Point))

 

Hello all. Need some help.

In my EA, it opens a series of orders in the number specified in the MaxOrders parameter. Below I have given an example of what this looks like, don't judge by lots

1-order-lot=128

2-lot-order-lot=256

3-lot-order=512

4-order-lot=1024

5-order-lot=2048

this is what you need for your tester.

MaxOrders=5, and 5 orders are open. The problem is that in the broker's tester, lot limited to 1000 is 4 and 5 orders will not open as required.

I searched through the Internet looking for a way to change this parameter in the Strategy Tester, I failed to find out how to do it.

Thus, I have decided to solve this issue using programming. I have decided to open several orders for 4 orders and get two

4-order-lot=1000

4-order-lot=24

for 5 orders 3:

5-order-lot=1000

5-order-lot=1000

5-order-lot=48

but there are two problems,

- how to divide the MM properly so that it would divide into lots according to max lot

- How to open additional orders without disturbing the order, i.e. there will be more orders than in maxOrders but don't consider additional ones that are opened to keep volume.

Reason: