AFL dumping wrong data to file

iTrade

Well-Known Member
#1
Hi,

I am using real time feed in amibroker.
Below the AFL that I am facing issue with. When I attach the AFL to the
chart, it dumps the last candle (any timeframe) data in a file. But the value
dumped in the file is way too different from what I see on the chart for the last candle. Anyone has nay clue if my script has any issue????


_SECTION_BEGIN("Write Data");
filename = "c:\\stock.txt";
{
ttime=TimeNum();
fh = fopen( filename, "w");
if( fh )
{


m = Month();
d = Day();
y = Year();

qs = StrFormat("%.2f, %.2f, %.2f, %.2f, %.0f\n",
O[ 1], H[ 1 ], L[ 1], C[ 1],ttime );
fputs( qs, fh );

fclose( fh );
}
}

_SECTION_END();
 
Last edited:

mastermind007

Well-Known Member
#3
Hi,

I am using real time feed in amibroker.
Below the AFL that I am facing issue with. When I attach the AFL to the
chart, it dumps the last candle (any timeframe) data in a file. But the value
dumped in the file is way too different from what I see on the chart for the last candle. ....

_SECTION_BEGIN("Write Data");
... qs = StrFormat("%.2f, %.2f, %.2f, %.2f, %.0f\n",
O[ 1], H[ 1 ], L[ 1], C[ 1],ttime );
_SECTION_END();
Use
LastValue(O), LastValue(H), LastValue(L), LastValue(C),ttime )

instead!

P.S. I saw your second post after I had already posted mine.... Glad you figured it out on your own....
 

Similar threads

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?