Current Bid/Ask price to CSV file.

 

Suppose I want to output the current Bid/Ask price to a CSV file.

Whenever the price changes, I want the file to update.

I was thinking something along the lines of this might work.

double PreviousAsk;

//+------------------------------------------------------------------+
int init()
  {
  
  int handle;
  handle=FileOpen("foo", FILE_CSV|FILE_WRITE, ';');
  if((handle>0) && Ask != PreviousAsk)
   
       for (int Counter = 1; Counter <= 100000; Counter++)
    {
     FileWrite(handle, "Bid is...",Bid, "Ask is...", Ask, "Spread is ...", (Ask - Bid));
    
  PreviousAsk = Ask;  
  }
   FileClose(handle);


But, alas, no.

Can anybody help me out?


Thanks, as usual.

 
monkeybus:

Suppose I want to output the current Bid/Ask price to a CSV file.

Whenever the price changes, I want the file to update.

I was thinking something along the lines of this might work.


But, alas, no.

Can anybody help me out?

What is in your start() function ? init() is called just once . . .

 
I only posted a section of the code.
 
monkeybus:
I only posted a section of the code.
OK . . . I only posted a section of my answer . . .
 

Here is the next section.

Read the documentation . . .

"If FILE_WRITE does not combine with FILE_READ, a zero-length file will be opened. If even the file containd some data, they will be deleted. If there is a need to add data to an existing file, it must be opened using combination of FILE_READ | FILE_WRITE."
 
RaptorUK:
OK . . . I only posted a section of my answer . . .


LOL
Reason: