Amibroker data Export in Ninja format Afl

#1
-.txt format can changed to csv-Just Find and replace .txt with .csv
-creat each txt file with 100000 1min data quotes.
Copy Paste and test before using
-----------------------------------------------------------------------
Code-
-----------------------------------------------------------------------

fmkdir( "C:\\AmiBackup" );
SetBarsRequired(100000,100000);
lname = Name();

fh = fopen( "c:\\AmiBackup" + lname + ".txt", "w");
if( fh )
{
y = Year();
m = Month();
d = Day();
r = Hour();
e = Minute();
s=Second();

for( i = 0; i < BarCount; i++ )

{
//fputs( Name() + "," , fh );
ds = StrFormat("%02.0f%02.0f%02.0f ",y[ i ], m[ i ], d[ i ] );

fputs( ds, fh );

ts = StrFormat("%02.0f%02.0f%02.0f;",r[ i ],e[ i ],s[ i ]);

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

fputs( qs, fh );
if(i == 100000 OR i == 200000 OR i == 300000 OR i == 400000 OR i == 500000 OR i == 600000 OR i== 700000 OR i == 800000 OR i == 900000 OR i == 1000000 OR i == 1100000 OR i == 1200000 OR i == 1300000 OR i == 1400000 OR i== 1500000 OR i == 1600000)
{
fclose( fh );
if(i == 100000 ) fh = fopen( "c:\\AmiBackup" + lname + " 1.txt", "w");
if(i == 200000 ) fh = fopen( "c:\\AmiBackup" + lname + " 2.txt", "w");
if(i == 300000 ) fh = fopen( "c:\\AmiBackup" + lname + " 3.txt", "w");
if(i == 400000 ) fh = fopen( "c:\\AmiBackup" + lname + " 4.txt", "w");
if(i == 500000 ) fh = fopen( "c:\\AmiBackup" + lname + " 5.txt", "w");
if(i == 600000 ) fh = fopen( "c:\\AmiBackup" + lname + " 6.txt", "w");
if(i == 700000 ) fh = fopen( "c:\\AmiBackup" + lname + " 7.txt", "w");
if(i == 800000 ) fh = fopen( "c:\\AmiBackup" + lname + " 8.txt", "w");
if(i == 900000 ) fh = fopen( "c:\\AmiBackup" + lname + " 9.txt", "w");
if(i == 1000000 ) fh = fopen( "c:\\AmiBackup" + lname + " 10.txt", "w");
if(i == 1100000 ) fh = fopen( "c:\\AmiBackup" + lname + " 11.txt", "w");
if(i == 1200000 ) fh = fopen( "c:\\AmiBackup" + lname + " 12.txt", "w");
if(i == 1300000 ) fh = fopen( "c:\\AmiBackup" + lname + " 13.txt", "w");
if(i == 1400000 ) fh = fopen( "c:\\AmiBackup" + lname + " 14.txt", "w");
if(i == 1500000 ) fh = fopen( "c:\\AmiBackup" + lname + " 15.txt", "w");
if(i == 1600000 ) fh = fopen( "c:\\AmiBackup" + lname + " 16.txt", "w");
}
}
fclose( fh );
}

Buy = 1;
 

trash

Well-Known Member
#2
That code is meant to be as a joke, right?
Well quite frankly, it is.

For example have you ever heard of modulo operation?
If so then re-think the code.
 
#3
That code is meant to be as a joke, right?
Well quite frankly, it is.

For example have you ever heard of modulo operation?
If so then re-think the code.
Dear,
I don't have knowledge in AFL coding!
I have similar code for amibroker data export for backup purpose(found on google)! and i have just done copy past to modify original Ninja format code which is producing only few day data export.
Purpose is to break exported file at 100000 quotes so it give multiple small files rather that one big file!
This Joke code served my purpose in exporting data from ami in ninja format to backfill in ninja and therefore i shared it.
 

trash

Well-Known Member
#4
Dear,
I don't have knowledge in AFL coding!
I have similar code for amibroker data export for backup purpose(found on google)! and i have just done copy past to modify original Ninja format code which is producing only few day data export.
Purpose is to break exported file at 100000 quotes so it give multiple small files rather that one big file!
This Joke code served my purpose in exporting data from ami in ninja format to backfill in ninja and therefore i shared it.
I know that you want to make chunks. I'm not a copy&paste guy but am able to think and understand. So that's why I told you that the way "your" code is handling it is not a good way.

Copy&paste is not a good idea (even more so if you don't understand what you have copy&pasted there). Thing is, bad code should not serve a role model to make a code even worse. That's why I'm saying that that code example is not optimal one so that others don't think it is optimal. No, it's not optimal. It's far away from it.

Once again I ask you, have you ever heard of modulo operation? If you don't have any knowledge (as you say) then it is not the best excuse because if you present something as your own one then you should not have a problem to be put to test in order to see if you even understand what you are doing there. So if I tell you that "your" way isn't a good idea then it should be stimulus to gain some knowledge making it better.
 
#5
dear @trash
I know your expert and You can modify it in more technical form.
I don't heard about modulo operation, and will try to know about it and will try to make code more technical!
 

trash

Well-Known Member
#6
dear @trash
I know your expert and You can modify it in more technical form.
I don't heard about modulo operation, and will try to know about it and will try to make code more technical!
Try here then
https://en.wikipedia.org/wiki/Modulo_operation

How would you change your code (if not using modulo) and you would want to make chunks of 10000 bars while having barcount of 1 million bars?
Are you saying that you would create 100 if statements? Since we don't want to do stupid things read the upper link.

What I'm trying to say is that if using modulo then the code will have the same length no matter what's your set chunk size!

BTW "your" code has some other exporting error.
 
Last edited:
#7
Try here then
https://en.wikipedia.org/wiki/Modulo_operation

How would you change your code (if not using modulo) and you would want to make chunks of 10000 bars while having barcount of 1 million bars?
Are you saying that you would create 100 if statements? Since we don't want to do stupid things read the upper link.

What I'm trying to say is that if using modulo then the code will have the same length no matter what's your set chunk size!

BTW "your" code has some other exporting error.
Dear,
Plz Check my Post Again i didn't said 10000 , i said 100000!
It didn't produce 100 of statement! For Nifty Future data from 2008 it produce seven 3.5MB file!
Code is working fine for me without any error!
Have a Great Day!
 

trash

Well-Known Member
#8
Dear,
Plz Check my Post Again i didn't said 10000 , i said 100000!
It didn't produce 100 of statement! For Nifty Future data from 2008 it produce seven 3.5MB file!
Code is working fine for me without any error!
Have a Great Day!
Well, you don't understand anything I wrote (what a surprise... another ignorant newbie). So forget it...
 

Similar threads