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

 
Thank you all very much, everything is working as it should! I wish I had smiley faces, I'd like to put a bunch :)
 
oleg_felix: How do I set the time frame in which trades will be executed? (start time and end time)

see here: https://www.mql5.com/ru/forum/135030

 
Helped, thanks, got it sorted out in time!
 

Please tell me how to write a simple command:

- totransfer an order to a lossless position for a given number of pips

 
oleg_felix:

Can you please tell me how to write a simple command:

- Set in an open order, stoploss to breakeven (considering the spread) at a certain amount of profit in the trade.

here is a function to convert all orders with the same magic number to b/w, try to experiment with it


extern int     LevelWLoss        = 100;       // Уровень безубытка в пп
extern int     LevelProfit       = 300;       // Уровень профита в пп
//+----------------------------------------------------------------------------+
//|  Перенос стопа в безубыток                                                 |
//+----------------------------------------------------------------------------+
void MovingInWL(int Magic) {
  int i, k;
  string sym;
  double ord_open,ord_TP,ord_SL;
  
  k = OrdersTotal()-1;
  sym = Symbol();
  for (i=k; i>=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==sym && OrderMagicNumber()==Magic) {
        ord_open = OrderOpenPrice();
        ord_TP   = OrderTakeProfit();
        ord_SL   = OrderStopLoss();
        if (OrderType()==OP_BUY) {
          if (NormalizeDouble(ord_SL,Digits)==NormalizeDouble(0,Digits) || 
              NormalizeDouble(ord_SL-ord_open,Digits)<NormalizeDouble(LevelWLoss*Point,Digits)) {
            if (NormalizeDouble(Bid-ord_open,Digits)>NormalizeDouble(LevelProfit*Point,Digits)) {
              OrderModify(OrderTicket(), ord_open, NormalizeDouble(ord_open+LevelWLoss*Point,Digits), ord_TP, 0, Yellow);
            }
          }
        }
        if (OrderType()==OP_SELL) {
          if (NormalizeDouble(ord_SL,Digits)==NormalizeDouble(0,Digits) || 
              NormalizeDouble(ord_open-ord_SL,Digits)<NormalizeDouble(LevelWLoss*Point,Digits)) {
            if (NormalizeDouble(ord_open-Ask,Digits)>NormalizeDouble(LevelProfit*Point,Digits)) {
              OrderModify(OrderTicket(), ord_open, NormalizeDouble(ord_open-LevelWLoss*Point,Digits), ord_TP, 0, Yellow);
            }
          }
        }
      }
    }
  }
return;
}
//_______________________________________________________________________
 

IgorM


Here is my EA code: Where do I want to insert the Breakeven function?

extern int tp = 0;

extern int sl = 0;

extern int BeginHour = 0; // start time

extern inttern EndHour = 0; // end time

int start()

{

//----

if(OrdersTotal()==0 && Hour() >= BeginHour && Hour() < EndHour && Close[1]<Open[1] && High[1]<Bid) // check if the price of the previous bar is lower than the open one. Buy order when the price of reaches the Bid price of the current bar, the high level of the previous bar.

OrderSend(Symbol(),OP_BUY,1,Ask,0,Ask-sl*Point,Ask+tp*Point,"",777,0,Red);

if(OrdersTotal()==0 && Hour() >= BeginHour && Hour() < EndHour && Close[1]>Open[1] && Low[1]>Bid) // check if the order is opened and the close price of the previous bar is lower than the open price. Buy order when the price reaches the current bar price Bid , high level of the previous bar.

OrderSend(Symbol(),OP_SELL,1,Bid,0,Ask+sl*Point,Ask-tp*Point,"",777,0,Red);

//----

return(0);

}

 
oleg_felix:

Here's my EA code: Where should I put the Breakeven function?

I think at this stage it's enough to add my function to the end of your code and do the following in your code at least:

if(OrdersTotal()> 0) MovingInWL(777);

Add to the beginning of your code

extern int LevelWLoss = 100; // Breakeven level in pips
extern int LevelProfit = 300; // Profit level in pips

I have doubts that you will solve this problem by yourself :)

 
DmitriyN:
You can. It is also possible to manage an account from a computer that is set up at work, or vice versa, when you are at home.
Thank you.
 

I tried to re-do someone else's function, and "a little" messed up, here's a piece of code:

string FileName = test.txt;

int FileHandle=FileOpen(FileName,FILE_READ);
  if (FileHandle < 0)
     {
       Print("Файл не найден.");
     }
  
  string strInfo;
  int i;
  if (FileHandle>0)
     {
     while (i<20)
        {
          if (FileHandle == 1)
            {
            string strInfo1=FileReadString(FileHandle);
            }else{
                 if (FileHandle == 2)
                    {
                    string strInfo2=FileReadString(FileHandle);
                    }else{
                         if (FileHandle == 3)
                              {
                            string strInfo3=FileReadString(FileHandle);
                              }else{
                                   if (FileHandle == 4)
                                       {
                                       string strInfo4=FileReadString(FileHandle);
                                       }else{
                                            if (FileHandle == 5)
                                               {
                                               string strInfo5=FileReadString(FileHandle);
                                               }else{
                                                    if (FileHandle == 6)
                                                       {
                                                       string strInfo6=FileReadString(FileHandle);
                                                       }else{
                                                            if (FileHandle == 7)                                                            
                                                               {
                                                               string strInfo7=FileReadString(FileHandle);
                                                               }else{
                                                                    if (FileHandle == 8)                                                                    
                                                                        {
                                                                        string strInfo8=FileReadString(FileHandle);
                                                                        }else{
                                                                             if (FileHandle == 9)
                                                                                 {
                                                                                 string strInfo9=FileReadString(FileHandle);
                                                                                 }else{
                                                                                      if (FileHandle == 10)
                                                                                         {
                                                                                         string strInfo10=FileReadString(FileHandle);
                                                                                         }else{
                                                                                              Print("Ошибка! В файле должно быть не более 10 записей!");
                                                                                              }
                                                                                      }
                                                                             }
                                                                    }
                                                            }
                                                    }
                                            }
                              
                                   }
                          }
                   
                               
             
          }
          if (StrToInteger(strInfo1)==12345||StrToInteger(strInfo2)==12345||
              StrToInteger(strInfo3)==12345||StrToInteger(strInfo4)==12345||
              StrToInteger(strInfo5)==12345||StrToInteger(strInfo6)==12345||
              StrToInteger(strInfo7)==12345||StrToInteger(strInfo8)==12345||
              StrToInteger(strInfo9)==12345||StrToInteger(strInfo10)==12345)
          {
          isNumInFile = TRUE;
          }

        if (FileIsEnding(FileHandle) && isNumInFile == FALSE)
           {
           Print("Достигнут конец файла, искомое значение не найдено");
           break;
           }
        i++;

        if (i>100) break;
        }
     FileClose(FileHandle);
     }

I wanted it to find a certain value in first 10 lines of test.txt file and if the number of lines is more than 10 it will give error "Error! There should be no more than 10 records in the file!", but for some reason it still goes through all the records, please help me to fix it, and if you can simplify the code and make it as a separate function.

 

People, please explain in a simple form, what is parameter transfer by reference. I read documentation, but understood only that it is possible and after variable identification it is obligatory to put modifier &. It would be great if the explanation was accompanied by a small program with explanations... What is the difference between usual parameter passing and passing parameters by reference?