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

 
CJIeCaPb:

Where the mistake is, I don't know.

Ope.

Something is wrong in the while(O==3) loop

 
CJIeCaPb:

Something is wrong in the while(O==3) loop

Phew... That's it, I've figured it out. After closing, the ticket is deleted and the order has to be re-run
 
Hello! This is the problem, I can't open the file. Tried different file extensions, to no avail, just gives out: error 5004. The file is in the file sandbox. It's all about the handle, but I have no idea why. Here's the code:
   int filehandle=FileOpen("test.txt",FILE_TXT|FILE_WRITE,";");
   if(filehandle<0)
   Alert("ошибка ",GetLastError());                          //Для проверки handle

 
 int filehandle=FileOpen("test.txt",FILE_WRITE|FILE_TXT,";");
 
evillive:
Tried without the separator - no use.
 
Kapizdo4ka:
Hello, I have this problem, I can't open the file. Tried different file extensions, no use, just gives out: error 5004. File is in file sandbox. It's the handle, but I have no idea why. Here's the code:

Have you tried specifying that the file is in a shared folder

File open flags

The values of the flags that define how the file will be handled. Flags are defined as follows:

Identifier

Value

Description

FILE_READ

1

File is opened for reading. This flag is used when opening a file (FileOpen()). FILE_WRITE and/or FILE_READ must be set when a file is opened.

FILE_WRITE

2

File is opened for writing. This flag is used to open a file (FileOpen()). When a file is opened, the FILE_WRITE and/or FILE_READ flags must be set.

FILE_BIN

4

Binary read-write mode (no conversion from or to string). This flag is used to open files (FileOpen())

FILE_CSV

8

File of csv type (all items written are converted to a string of the appropriate type, unicode or ansi, and separated by a separator). This flag is used when opening a file (FileOpen())

FILE_TXT

16

Simple text file (same as csv, but without separator). This flag is used when files are opened (FileOpen())

FILE_ANSI

32

ANSI strings (single-byte characters). This flag is used when opening files (FileOpen())

FILE_UNICODE

64

UNICODE strings (two-byte characters). This flag is used when opening files (FileOpen())

FILE_SHARE_READ

128

Shared read access by multiple programs. This flag is used when opening a file (FileOpen()), but does not substitute the need for FILE_WRITE and/or FILE_READ when opening a file.

FILE_SHARE_WRITE

256

This flag is used for write access sharing by multiple programs. This flag is used to open files (FileOpen()), but does not substitute FILE_WRITE and/or FILE_READ when opening a file.

FILE_REWRITE

512

File can be overwritten by FileCopy() and FileMove(). The file must exist or be writable. Otherwise, file will not be opened

FILE_COMMON

4096

Location of file in shared folder of all client terminals\Terminal\Common\Files . This flag is used when opening files (FileOpen()), copying files (FileCopy(), FileMove()) and checking for the existence of files (FileIsExist())

One or more flags can be specified when opening a file, this combination is called a combination of flags. The combination of flags is written using the logical OR (|) operation sign that is placed between the flags being enumerated. For example, to open a CSV file for reading and writing at the same time, you can specify the combination FILE_READ|FILE_WRITE|FILE_CSV.

 
Vinin:

Have you tried specifying that the file is in a shared folder

File open flags

The values of the flags that define how the file will be opened. Flags are defined as follows:

Identifier

Value

Description

FILE_READ

1

File is opened for reading. This flag is used when opening a file (FileOpen()). FILE_WRITE and/or FILE_READ must be set when the file is opened.

FILE_WRITE

2

File is opened for writing. This flag is used when opening a file (FileOpen()). The FILE_WRITE flag must be set and/or the FILE_READ flag must be set when a file is opened.

FILE_BIN

4

Binary read-write mode (unconverted to and from string). This flag is used to open files (FileOpen())

FILE_CSV

8

csv file (all written elements are converted to a string of the appropriate type, unicode or ansi, and separated by a delimiter). This flag is used when opening files (FileOpen())

FILE_TXT

16

Simple text file (same type, but delimiter is ignored). This flag is used when opening a file (FileOpen())

FILE_ANSI

32

String of ANSI type (single-byte characters). This flag is used when opening files (FileOpen())

FILE_UNICODE

64

UNICODE strings (two-byte characters). This flag is used when opening files (FileOpen())

FILE_SHARE_READ

128

Shared read access between multiple programs. This flag is used when opening a file (FileOpen()), but does not substitute for specifying FILE_WRITE and/or FILE_READ when opening a file.

FILE_SHARE_WRITE

256

This flag is for write access shared by multiple programs. This flag is used to open files (FileOpen()), but does not substitute for the need to specify FILE_WRITE and/or FILE_READ flags when opening a file.

FILE_REWRITE

512

FileCopy() and FileMove() can be used to overwrite a file. The file must exist or be writable. Otherwise, file will not be opened

FILE_COMMON

4096

Location of file in shared folder of all client terminals \Terminal\Common\Files . This flag is used when opening files (FileOpen()), copying files (FileCopy(), FileMove()), and checking for the existence of files (FileIsExist())

When opening a file, one or more flags can be specified, this combination is called a combination of flags. A combination of flags is recorded using the logical OR sign (|) placed between the listed flags. For example, to open a CSV file for reading and writing at the same time, you can specify the combinationFILE_READ|FILE_WRITE|FILE_CSV.

Thank you! However, the answer turned out to be much simpler. All because of the changes in the new build. It turns out that the FileOpen function must now specify the uint type instead of the int type, as in the previous version:
uint filehandle=FileOpen(filename,FILE_TXT||FILE_WRITE,"\r\n");

And now in case of an error the function returns 0 instead of -1.

 

Sketched a simple Trailing Stop. bez_Level - Trailing start level in pips. TrallStep - trailing step. Magic - number of Magic.

The problem is that, if several orders are opened by the Expert Advisor, only the first order is trilled. And, when the first order is closed, the second one starts trilling. I do not get any error messages. I cannot try to find out what I have done wrong. Thank you...

int lim=OrdersTotal()-1;

for(int i=lim; i>=0; i--)
{
if(bez_Level>0)
{
if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
{
if(OrderType()==OP_SELL)
{
{ if((OrderOpenPrice()-Ask)>(Point*bez_Level))
{
if((OrderStopLoss()>(Ask+Point*bez_Level)+(Point*TrallStep)) || (OrderStopLoss()==0))
{
//--- modify order and exit
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*bez_Level,OrderTakeProfit(),0))
Print("Trailing error ",GetLastError());
}
}
}
if(OrderType()==OP_BUY)
{
if((Bid-OrderOpenPrice()>Point*bez_Level))
{
if(OrderStopLoss()<Bid-(Point*bez_Level)-(Point*TrallStep))
{
//--- modify order
if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*bez_Level,OrderTakeProfit(),0))
Print("Trailing error ",GetLastError())
}
}

}

}
}
}
 

Guys, what's the trick? Why isn't it coming out of Inita?

WHY THERE IS NO ENTRY TO START?????????

int init()
 {
   if(init_data()==false)error=true;
   if(error==false)load_data();
   if(error==false)count_data();
   //if(error==true)Print("---------->>>>>>> ERORR!!! <<<<<<<<<--------------");
   setparam();
   Print ("Инит завершён успешно");
   return (0);
 }

int start()
{
  // if(iTime(Symbol(),0,0) == prevtime) return(0);    //ждем нового бара
 //  prevtime = iTime(Symbol(),0,0);                   //если появился новый бар , включаемся    
   Print (" Старт после нового бара"); 
...
      
 
_Roman:

Guys, what's the trick? Why isn't it coming out of Inita?


Why isn't it coming out, isn't it saying it's successful?
Reason: