Can't I export quotes using this code without opening a chart

 

I have a script to export quotes but it only works if I open a chart. Can't I modify so that I'm not obliged to open a chart first ?

Excerpt of source code :

FileWrite(handle, "Time;Open;High;Low;Close;Volume");

// data recording

for(int i=iBars(symbol,theperiod); i>=0; i--) {



datetime t = iTime(symbol,theperiod,i);

// int year = TimeYear(Time[i]);

int year = TimeYear(t);

if (year > 1970) {



string strdatetime = TimeToStr(t);

strdatetime = StringSetChar(strdatetime,4,'-');

strdatetime = StringSetChar(strdatetime,7,'-');

double Open_i = iOpen(symbol,theperiod,i);

double High_i = iHigh(symbol,theperiod,i);

double Low_i = iLow(symbol,theperiod,i);

double Close_i = iClose(symbol,theperiod,i);

double Volume_i = iVolume(symbol,theperiod,i);

FileWrite(handle, strdatetime, Open_i, High_i, Low_i, Close_i, Volume_i);

}

}

FileClose(handle);
 
forexgenuine:

I have a script to export quotes but it only works if I open a chart. Can't I modify so that I'm not obliged to open a chart first ?

Excerpt of source code :

<CODE REMOVED>

Please edit your post . . . please use the SRC button to post code: How to use the SRC button.
 
forexgenuine: I have a script to export quotes but it only works if I open a chart. Can't I modify so that I'm not obliged to open a chart first ?
Where do you think it gets the prices from?
 
WHRoeder:
Where do you think it gets the prices from?

Well I thought that Bars was for current chart and iBars( string symbol, int timeframe) wouldn't need any chart since symbol and timeframe have been given.
 
RaptorUK:
Please edit your post . . . please use the SRC button to post code: How to use the SRC button.

done thanks didn't see src in the first place ;)
 
WHRoeder:
Where do you think it gets the prices from?

I think it is ok, the symbol, theperiod parameters are not taken from the opened chart, can be anything. From one chart you can access all other existing chart and timeframe data.

I think the problem is that the chart is the only "interface" for running a task (script), an opened chart is needed for tasks that do not even require any chart.

 
  1. It's ok, as long as you handle 4066
  2. Scripts run on a chart. The OP wanted one to run with no chart. Thus my original comment.
 
forexgenuine:

This is my second unsuccessfull attempt to export ticks to a file after getting some help I corrected but still the file is created but stays empty why :


You FileOpen() the file tick after tick after tick . . . why ?

1.33685 1.33690 1.33684 1.33688

1.33685 1.33695 1.33684 1.33688

1.33717 1.33718 1.33710 1.33713

1.33717 1.33718 1.33710 1.33710

1.33717 1.33718 1.33710 1.33715

1.33717 1.33718 1.33710 1.33715

1.33717 1.33718 1.33710 1.33714

1.33717 1.33718 1.33710 1.33715

1.33717 1.33718 1.33710 1.33716

1.33717 1.33719 1.33710 1.33719

1.33717 1.33719 1.33710 1.33718

Files:
 
RaptorUK:


You FileOpen() the file tick after tick after tick . . . why ?

1.33685 1.33690 1.33684 1.33688

1.33685 1.33695 1.33684 1.33688

1.33717 1.33718 1.33710 1.33713

1.33717 1.33718 1.33710 1.33710

1.33717 1.33718 1.33710 1.33715

1.33717 1.33718 1.33710 1.33715

1.33717 1.33718 1.33710 1.33714

1.33717 1.33718 1.33710 1.33715

1.33717 1.33718 1.33710 1.33716

1.33717 1.33719 1.33710 1.33719

1.33717 1.33719 1.33710 1.33718


Oh yeah thank you very that works it saves my life !

 
forexgenuine:


Oh yeah thank you very that works it saves my life !

Do you understand why ?
Reason: