Hi,
I have used the following code to export intraday minute data to a txt file. I use Scan to do so. How do I do the same for N-volume bar data as the periodicity settings don't allow for n-volume bars?
oc=ln(C/o);
dco=ln(O/Ref(C,-1));
ol=ln(L/O);
oh=ln(H/O);
tim=Hour()*100+Minute();
dat=datenum();
C_new=ln(C);
o_new=ln(o);
l_new=ln(l);
h_new=ln(h);
const=934;
for( i=1; i<BarCount; i++ )
{ if ( dat[i] != dat[i-1] )
{ o_new[i]=C_new[i-1];
}
else
{ O_new[i]=C_new[i-1]+dco[i];
}
C_new[i]=O_new[i]+oc[i];
h_new[i]=O_new[i]+oh[i];
L_new[i]=o_new[i]+ol[i];
}
C=round(exp(c_new)*100)/100;
O=round(exp(O_new)*100)/100;
L=round(exp(L_new)*100)/100;
H=round(exp(H_new)*100)/100;
//Plot(tim,"c", colorGreen, styleLine);
/*
Plot(exp(o_new),"o", colorgreen, styleLine);
Plot(exp(l_new),"l", colorred, styleLine);
Plot(exp(h_new),"h", colorblue, styleLine);
*/
fh = fopen( "C:\\Users\\name\\OneDrive\\Documents\\TS\\data\\"+Name()+"_5vol.txt", "w");
if( fh )
{
y = Year();
m = Month();
d = Day();
r = Hour();
e = Minute();
for( i = 0; i < BarCount; i++ )
{
//fputs( "," , fh );
ds = StrFormat("%02.0f%02.0f%02.0f,",
y[ i ], m[ i ], d[ i ] );
fputs( ds, fh );
ts = StrFormat("%02.0f%02.0f,",
r[ i ],e[ i ] );
fputs( ts, fh );
qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f\n",
O[ i ],H[ i ],L[ i ],C[ i ],V[ i ] );
fputs( qs, fh );
}
fclose( fh );
}
Buy = 0;
Thanks