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

 
Yeah, right!!!
 

Here's how it doesn't modify bye - and it's a zircal condition, and it also doesn't work all the time.

This is the place.

//***************************************   
 
 bool nahodka=false;
 
 for (i=0; i<=OrdersHistoryTotal(); i++) {
 if (!OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) continue;
 if (OrderSymbol()!=Symbol())continue; 
 if (OrderMagicNumber() != 450) continue; Print (" tacket ",tacket, "  OrderTicket() ",OrderTicket(),"    profit " , profit, "    OrderTakeProfit( ) ",OrderTakeProfit( ) );
 if (tacket==OrderTicket()) {Print ("tacket==OrderTicket()    " );
 if (OrderTakeProfit( )-3*Point<profit&&OrderTakeProfit( )+3*Point>profit) nahodka=true;}}     // Находим ордер, сработавший именно по тейкпрофиту 
 
 
  
 if(nahodka){if (OrderSelect(tucket,SELECT_BY_TICKET)){
 if(OrderStopLoss( )<Bid-treylingstop*Point ){ Print ("втораямодифи    " );
 OrderModify(  tucket, OrderOpenPrice(), Bid-treylingstop*Point, OrderTakeProfit(), 0, CLR_NONE);}}}
 if (BUY == 0) {perenos=false;srabotka=false;nahodka=false;} 
 
 
 //*************************************** 
 
 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
 
               
               //SELL
 
Dimka-novitsek:

Good morning!

I categorically cannot figure it out - conditions for trailing stop do not work.

So, the order is taken away immediately when it's not yet on the history, which I don't understand at all!

And this is the situation is better! If we have this trick, at least the order is corrected when it is already on the history.

But once in five or ten times nahodka does not take the valuetrue, and further modification does not occur!


Have you tried if(OrderClosePrice()==OrderTakeProfit())nahodka=true;?
 
Dimka-novitsek:

Good morning!

I categorically cannot figure it out - conditions for trailing stop do not work.

So, the order is taken away immediately when it's not yet on the history, which I don't understand at all!

And this is the situation is better! If we have this trick, at least the order is corrected when it is already on the history.

But once in five or ten times nahodka does not take the value true, and further modification does not occur!

When selecting an order by ticket, the pool is not taken into account. Therefore, it is absolutely useless to write MODE_HISTORY. After the order is selected according to the ticket, you should also necessarily check its closing time OrderCloseTime() - if it is higher than zero, the order is closed and selected from the history, if it is zero, then the order is still in the market and is selected from the list of market positions.

This check is not present in your lines:

if (OrderSelect(tacket, SELECT_BY_TICKET , MODE_HISTORY)) 
if (OrderTakeProfit( )-3*Point<profit&&OrderTakeProfit( )+3*Point>profit) nahodka=true;     // Находим ордер, сработавший именно по тейкпрофиту 

You have to start small:

if (OrderSelect(tacket, SELECT_BY_TICKET)) {
   if (OrderCloseTime()>0) {                         // Убедились, что ордер выбран из истории
      // Тут ищете далее то, что вам необходимо ... а закрылся ли он по тейку ...
      }
   }

and you will be happy...

 
Dimka-novitsek:

Good morning!

I categorically cannot figure it out - conditions for trailing stop do not work.

So, the order is taken away immediately when it's not yet on the history, which I don't understand at all!

And this is the situation is better! If we have this trick, at least the order is corrected when it is already on the history.

However, nahodka takes no valuetrue once out of five to tenand there is no further modification!

! - It is your ingenuity to name the Ticket: tecket, tocket, tucket, etc. etc. Aren't you confused in these names yourself! My advice to you - to avoid confusion, don't do so. This is how LochBranding is built upon, for example: ADIDAS and ADITAS...

Also, there is no point in having so many flags, e.g:

     if (OrderSelect (ticket, SELECT_BY_TICKET))
     {
         //---- Проверяем закрыт этот ордер или нет
         if (OrderCloseTime > 0)
         {
             //---- Находим ордер, сработавший именно по тейкпрофиту 
             if (NormalizeDouble (OrderTakeProfit()- OrderClosePrice()), Digits) == 0.0)
             {
                 if (OrderSelect (tucket, SELECT_BY_TICKET))
                 {
                     double ld_SL = NormalizeDouble (Bid - treylingstop * Point, Digits);
                     if (NormalizeDouble (ld_SL - OrderStopLoss(), Digits) > 0.0)
                     {
                         Print ("втораямодифи    " );
                         OrderModify (tucket, OrderOpenPrice(), ld_SL, OrderTakeProfit(), 0, CLR_NONE);
                     }
                 }
             }
         }
     }
This is an easy improvisation based on your code.
 
Thank you!!!!!!!
 
Dimka-novitsek:
Yeah, right!!!
Dimka-novitsek:

Here's how it doesn't modify bye - and it's a zircal condition, and it also doesn't work all the time.

This is the place.


It should not modify, because the last deal, and in general all on the given chart are closed on sl
 
lottamer:

it turns out that the SecondsAfterOpenLastPos() function from Kim's library returns these numbers 1355319542 , and the last number is really seconds... you can see how they change.....

what is it? if it's really seconds - it's 43 years.... and a half.... and the function should return seconds from the time the last transaction was CLOSED...

Although it turned out that even OrderOpenTime gives time in the same format ... how to translate it into reverse? must apparently take the current time and subtract OrderOpenTime. How do I get the current time?


If you want to see the time in a format you are more accustomed to, use the conversion functions, there are many of them in the help section of the date and time, you can display the output in different formats, e.g. days, hours, minutes, time...

The last server time will be returned by iClose function for zero bar. Or justClose[0].

This function returns the last known price. Time will return

TimeCurrent( )
 
rigonich:


You have already been told that this is the time format the computer works with, and it is the only one it can work with. If you want to see the time in a more familiar format, use the translation functions, there are lots of them in the date and time help section, you can output whatever you want, separate days, hours, minutes, time in different formats...

The last server time will be returned by iClose function for zero bar. Or justClose[0].

This function returns the last known price. Time will return

TimeCurrent( )


managed to snag the post :))), although I deleted it...found out that the time is found by simply subtractingTimeCurrent()-OrderOpenTime()
 
lottamer:

managed to snag the post :))), although I deleted it...having found out that the time is found by simply subtracting TimeCurrent()-OrderOpenTime()

If you want me not to answer your questions -- just say so.
Reason: