[WARNING CLOSED!] Any newbie question, so as not to clutter up the forum. Professionals, don't go by. Can't go anywhere without you. - page 445

 

I have a problem that has reached a ridiculous point. Error in order closing function.

OrserClose(int tip){
if( tip==1){
for( i=0; i<OrdersTotal(); i++){
           if(true==OrderSelect( i, SELECT_BY_POS, MODE_TRADES)){
           if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && OrderMagicNumber() == Magic){
           OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet);
               }
           }
         }  
}

Gives an error (in different terminals)

EURCHF,M5: OrderClose error 4107

EURCHF,M5: invalid price 1.48566000 for OrderClose function


if I do

OrderClose(OrderTicket(), OrderLots(),OrderClosePrice(),3, Violet);
OrderClose(OrderTicket(),OrderLots(),MarketInfo(Symbol(),MODE_BID),3,Violet);

the same error. But when I write OrderClose(...) not in a separate function, but in int start(), this error doesn't occur .

What is the problem and how to fix it?



 
try running the cycle from end to beginning
for( i = OrdersTotal() - 1;  i > 0;  i--)
 
T-G >>:

У меня проблема до смешного дошла. Ошибка в функция закрытия ордера.

дает ошибку (причем в разных терминалах)

EURCHF,M5: OrderClose error 4107

EURCHF,M5: invalid price 1.48566000 for OrderClose function


если сделать

таже самая ошибка. но причем когда я пишу OrderClose(..) не в отдельной функции а в int start() то такой ошибки не возникает.

в чем дело и как вылечить?









normalise the price

 

int tick = 0, MaxTicks = 5;
bool SaveTickOn = 1;
string bid_s;

int start(){
   if( SaveTickOn){
      int rw_mode = FILE_CSV| FILE_READ| FILE_WRITE;
      if( tick == 0) rw_mode = FILE_CSV| FILE_WRITE;
      int handle1 = FileOpen("bids1.dat", rw_mode," ");
      bid_s = DoubleToStr(Bid,Digits); 
      FileWrite( handle1, bid_s);
      if(GetLastError() != 0) Alert("Error= ",GetLastError());
      Alert( tick,": ", bid_s);
      tick++;
      if( tick == MaxTicks) SaveTickOn = 0; 
      FileClose( handle1);
   }
   return(0);
}

There is a simple code to write to a file with an addendum, but for some reason the option to add to a file

FILE_READ| FILE_WRITE 

doesn't work.

What can it be?

 

Put this one in the start, it will close everything with a guarantee, just put in the conditions...

if ( Close_) {
for (int trade = OrdersTotal() - 1; trade >= 0; trade--) {
OrderSelect( trade, SELECT_BY_POS, MODE_TRADES);
if (OrderSymbol() == Symbol()) {
if (OrderSymbol() == Symbol() && OrderMagicNumber() == MagicNumber) {

if ((OrderType() == OP_BUY) &&( условие закрытия для бай)) OrderClose(OrderTicket(), OrderLots(), Bid, slip, Blue);
if ((OrderType() == OP_SELL)&&( условие закрытия для селл)) OrderClose(OrderTicket(), OrderLots(), Ask, slip, Red);
}
Sleep(1000);
}
}
}
 
Andrei01 >>:

Есть простейший код для записи в файл с добавлением, но почему то опция добавления в файл

не работает.

Что это может быть?

I also checked that the FileIsEnding(handle1) function returns zero, while it should be 1, i.e. there seems to be a bug in MT4 in the add to file mode.

 
Andrei01 писал(а) >>

I also checked that the FileIsEnding(handle1) function returns zero, while it should be 1, which means there must be a bug in MT4 in file add mode.

Have you tried to go to the end of the file? FileSeek()

 
//+------------------------------------------------------------------+
//| Write string to file |
//+------------------------------------------------------------------+
void WritingLineInFile(string FileName, string text)
{
int file_handle=FileOpen(FileName, FILE_READ|FILE_WRITE, " ");

if (file_handle>0)
{
FileSeek(file_handle, 0, SEEK_END);
FileWrite(file_handle, text);
FileClose(file_handle);
}

}
There are no bugs, you just need to write it correctly. This function adds text to FileName .
 

Hi!

I am trying to program it myself!

Help me figure out what direction to go in! If you need it urgently and quickly (for starters)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

There is a certain indicator consisting of two MA

We need to create a sound signal at the intersection of two MA with the message displayed using the "MessageBox" function.

What to do?

1 Create a script with the "MessageBox" function

2.Or add a condition to the indicator code with this function?

3.Or link an existing script to the indicator? How to link them, if possible?

4.Or it is easier to create an Expert Advisor?

If I have one, please send me the source code of a simple classic Expert Advisor with two moving averages

(EA conditions...buy if fast МА crosses (or touches) slow MA from bottom to top

..............................sel if fast МА crosses (or touches) a slow MA from the top to the bottom

.............................. with StopLoss function

.............................. with TakeProfit function

.............................. with Lot function

Thank you!

 
DRevodel писал(а) >>

Hi!

Trying to program on my own!

Help me to understand which direction to go! If you need it urgently and quickly (for starters)

There is a certain indicator consisting of two MA

You need to create a sound signal at the intersection of two MA with the message output on the screen using the "MessageBox" function.

What to do?

Or add a condition to the indicator code with this function?

>>Thank you!