[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 590

 
lottamer:

modification is going on for sure - the order is open - you have to set the stop-steaks...

Then why did you put it inside brackets { } if (cross averages for example)?
 

I'm becoming a mother in front of my eyes! (i.e. becoming a matriarch!) :))

here's the other thing.

If I modified an order, the notification window would pop up afterwards informing me that the order had been successfully modified. If I click OK in that window, it is too bad. Moreover, if I disable the EA after that window appears, then after pressing OK in the message window, the EA will ALWAYS REPAIR its actions (closing a position, in this case). Interesting thing - the EA is gone, but its commands are still executed!

I had to think a bit and remove the line

message=message+"Ordermodification error#"+OrderTicket()+" - "+type+" - "+DoubleToStr(OrderLots(), 2)+". "+error_desc+" \n"

After that everything went as it should. no windows... everything opens and closes... opens and closes... opens and closes...

:))))))))))))

P.S.

but if you remove

OrderPrint(); 

continue;

there is no change ... same thing with the line

if(ret==IDOK) return(0);

whether it is there or not - no change!

why is it so?

 
lottamer:


why?

if the order hasn't opened - what will you modify?

lottamer:

and is it possible to check My_buy (non-boolean variable) for TRUE-FALSE ?

so WHO'S the BOOCH PRAGRAMIST here?! you can always make a Boolean one out of a "non-Boolean one"!!!

lottamer:

the modification goes unconditionally - the order is open - you have to set the stops-stakes...

that's what checking for the fact that the order is OPEN is for.

You have bravely taken the next step in your knowledge of the language - you have become familiar with how libraries work:

#include <WinUser32.mqh>

this is the library - the standard one from MetaTrader delivery. People write their own (custom) libraries. An example of a library containing trade order functions. These functions are written once, and then used in their codes as needed.

 
sergeev:
Then why did you put it inside the brackets { } if (cross averages for example)?


so it would be there.

Where do you think it can be inserted? only immediately after an order is opened.

 
lottamer:

I'm becoming a mother in front of my eyes! (i.e. becoming a matriarch!) :))

why so?

I just need to look up "What is MessageBox()?" - via Ctrl+F1 in MetaEditor.
 
TarasBY:

if the order didn't open - what would you modify?

so WHO'S the BOH PRAGRAMIST here?! you can always make a Boolean one out of a "non-Boolean one"!!!

that's what the OPEN warrant check is for.

You have bravely taken the next step in learning the language - familiarising yourself with the workings of libraries:

this is the library - the standard one from MetaTrader delivery. People write their own (custom) libraries. An example of a library containing trade order functions. These functions are written once and then used in your codes as needed.


If the order hasn't opened, it cannot be modified, because there is nothing to modify. I haven't finished writing the whole EA yet, I'm writing it in blocks and checking it immediately, then I finish it and check again. But I don't think that if a deal won't open, then EA will be completely disabled, because it won't know what to do - there's an order to modify and there is no open position. :))) will open on next ticks...and then it will modify

2)BOH here you are uniquely, for I, a sinner, don't even understand how so Boolean-innon-Boolean... I.e. there is a usable function and let's say it was executed, i.e. the pose opened. So now the machine will understand that my usable function is now TRUE, because it has been executed? ..... sorry for not knowing the question

3) see 1

4)#include is a topic I'm too embarrassed to ask about!

i understand correctly, that theoretically, let's say, from my CLOSE_ALL and MODIFY scripts, you can make a#include instead of a custom function and refer to it.

but how would i insert this#include My_buy after the if condition?

 
TarasBY:
It's just a matter of looking up "What is MessageBox()?" - via Ctrl+F1 in MetaEditor.

this is a nuance...and I would like to finish the Expert Advisor now... :))
 

does anyone know about the rollover?

When orders are reopened with rollover, can there be slippages for stop and takeout values ? And how will the stop be set if after the rollover the difference between the open and stop price will be less than the stop leveller ?

My task is as follows. If i have an open market order, i should check if it was opened with rollover and if it was, i should get the ticket of the previous order, that was closed. Maybe someone will tell me the search algorithm? I am currently doing the following:

1. I select the first open order.
2. If it is opened from 23:40 to 00:20, then I continue to check this order further (40-minute window is taken just in case, although in theory you could take from 23:50 to 23:59)
3. I remember the ticket, stop and take price
4.I check all closed orders on the history, and comments contain the word "swap" and currency pairs match

5. I compare data on stops and takeovers, if they match, here it is the required order pair, if not - I return to step 1

 

Please tell me what is meant by

while(true)

in the modifier script that I pasted into the EA?

and what is this strange check for

if(cmd==OP_BUY || cmd==OP_SELL) ?

Wouldn't it be better just to check for the presence of an open position?

int My_modify ()
 {
//      bool   result;
//      double stop_loss,take_profit,point,bid,ask, lotsize;
//      int    cmd, total, error, spread;
//      string message;
//----
   total=OrdersTotal();

//----
   for(int i=0; i<total; i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         //---- print selected order
         OrderPrint();
         cmd=OrderType();
         point=MarketInfo(OrderSymbol(),MODE_POINT);
         bid= MarketInfo(OrderSymbol(),MODE_BID);
         ask= MarketInfo(OrderSymbol(),MODE_ASK);
         spread=MarketInfo(OrderSymbol(),MODE_SPREAD);     
         //---- buy or sell orders are considered
         if(cmd==OP_BUY || cmd==OP_SELL)
          {
            //---- modify first market order
            while(true)
             {
                if(cmd==OP_BUY){
                        string type = "buy";
                        if(OrderStopLoss()!=0)stop_loss=OrderStopLoss();
                        else stop_loss=OrderOpenPrice()-StopLoss*point;
                        if(OrderTakeProfit()!=0)take_profit=OrderTakeProfit();
                        else take_profit=OrderOpenPrice()+TakeProfit*point;
                }
                     
                else{
                        type = "sell";
                        if(OrderStopLoss()!=0)stop_loss=OrderStopLoss();
                        else stop_loss=OrderOpenPrice()+StopLoss*point;
                        if(OrderTakeProfit()!=0)take_profit=OrderTakeProfit();
                        else take_profit=OrderOpenPrice()-TakeProfit*point;
                }   
                result=OrderModify(OrderTicket(), OrderOpenPrice(), stop_loss, take_profit, 0, CLR_NONE);
                if(result!=true) { error=GetLastError(); Print("LastError = ",error);}
                else {error=0;}
                if(error==135) RefreshRates();
                else break;
              }
                if(error==0){
                        //message=message+"Ордер #"+OrderTicket()+" - "+type+" - "+DoubleToStr(OrderLots(), 2)+" успешно модифицирован.\n";
                        }
                        else{
                                if(error == 130){string error_desc = " - Неправильные стопы";} else error_desc = "";
                                if(error != 1)
                        message=message+"Ошибка модификации ордера #"+OrderTicket()+" - "+type+" - "+DoubleToStr(OrderLots(), 2)+". "+error_desc+" \n";
                        }

              //---- print modified order (it still selected after modify)
              OrderPrint();
              continue;             
           }
        }
      else { Print( "Error when order select ", GetLastError()); break;}
     }
        int ret=MessageBox(message, NULL, MB_OK);
        if(ret==IDOK) return(0);
//----
   return(0);
  }
 
lottamer:

This is a nuance ... and now I would like to finish the advisor ...:))

You want to "move the cart" for "Kucher's nose". With a low level of language skills, you need to start practicing with:

Take a ready working Expert Advisor, which is close to your strategy and modernize it to your needs - so it will be faster to understand and comprehend your actions (in the obvious absence of the desire to read "The Primer").

Good luck!

P.S. AXIOMA: "Coachmen do not ride on carts!!!"