Prevent Loop in AFL and How Amibroker Lock Files

Hi, I studying about w/r files in AFL. I didn't find this especific information in the forum so this is why I am here.

Two questions:

  1. How to prevent it to loop every single tick I get from the real time database? I know exrem, but I don't have any buy or sell in the following example:

Code:

// create folder for exporting purposes
fmkdir( "C:\\DataExport\\" );

// open file for writing
fh = fopen( "c:\\DataExport\\append_test.txt", "a", True );

// proceed if file handle is correct
if ( fh )
{
	for (i=0; i <= 100; i++)
	{

    // write line
    fputs( StrFormat("Formula1_%g\n", i), fh );

    }
    // close file handle
    fclose( fh );
}

"c:\DataExport\append_test.txt" is increasing in every tick (price change).

Next question.

  1. How Amibroker deals with locks? If a file is busy, what happens? Does it wait? Will I lose information?

To illustrate this problem, I created Formula 1 and Formula 2. They have the same code above. As result I guess it should write in the append_test.txt once Formula 1, once Formula 2. But it doen'st. Sometimes it repeat Formula1, sometimes Formula 2.

Capturar

  1. Use ParamTrigger http://www.amibroker.com/f?paramtrigger

  2. Knowledge Base: http://www.amibroker.com/kb/2016/01/27/how-to-write-to-single-shared-file-in-multi-threaded-scenario/

2 Likes

Thank you Tomasz. It worked fine. But I have one more issue for you. Please.
Is the same question of the unanswered topic below:

How to make all charts active even in normal mode window? The formulas in multiple tickers only are processed in floating windows. I understand the concern about memory allocation. But is there anyway to able formulas in different tabs?

@erictrevisani you will find an answer/solution here:

Thank you Milosz. You are right!

1 Like