Simple Coding Help - No Promise.

dell

Well-Known Member
use this

Code:
/*
Export EOD data to CSV/TXT files 
One file for each stock
In the first line insert the directory you want to save them to, make sure the directory exists
Select your charts to export with the "Apply to" filter in AA window 
Select the timeframe period you want to save as using the AA "Settings"
Press Scan button
by Graham Kavanagh 05 Feb 2004
*/

fh = fopen( "c:\\SAVEDATA\\"+Name()+".csv", "w"); 
if( fh ) 
{ 
   //fputs( "Ticker,Date,Open,High,Low,Close,Volume,Open Int\n", fh ); 
   y = Year(); 
   m = Month(); 
   d = Day(); 
      
   for( i = 0; i < BarCount; i++ ) 
   { 
      fputs( Name() + "," , fh );

      ds = StrFormat("%02.0f/%02.0f/%02.0f,", 
                     d[ i ], m[ i ], y[ i ] ); 
      fputs( ds, fh ); 
     
      qs = StrFormat("%.4f,%.4f,%.4f,%.4f,%.0f,%.0f,\n", 
                     O[ i ],H[ i ],L[ i ],C[ i ],V[ i ],OI [i] ); 
      fputs( qs, fh ); 
   } 

   fclose( fh ); 
} 

Buy = 0;
thanks sr114 sir , but my database contains rt data , i mean ieod data , can we use this afl to export to csv ? if no , than plz can u post additional lines .............
 

sr114

Well-Known Member
thanks sr114 sir , but my database contains rt data , i mean ieod data , can we use this afl to export to csv ? if no , than plz can u post additional lines .............
them the code is

HTML:
/*
Export intraday and EOD data to TXT files 
One file for each stock
In the first line insert the directory you want to save them to, make sure the directory exists
Select your charts to export with the "Apply to" filter in AA window 
Select the timeframe period you want to save as using the AA "Settings"
Press Scan button
by Graham Kavanagh 05 Feb 2004
*/

fh = fopen( "c:\\SaveData\\"+Name()+".csv", "w"); 
if( fh ) 
{ 
   //fputs( "Ticker,Date,Time,Open,High,Low,Close,Volume,OI \n", fh ); 
   y = Year(); 
   m = Month(); 
   d = Day(); 
   r = Hour();
   e = Minute();
   n = Second();
   
   for( i = 0; i < BarCount; i++ ) 
   { 
      fputs( Name() + "," , fh );
      ds = StrFormat("%02.0f-%02.0f-%02.0f,", 
                     d[ i ], m[ i ], y[ i ] ); 
      fputs( ds, fh ); 
     
      ts = StrFormat("%02.0f:%02.0f:%02.0f,", 
                     r[ i ],e[ i ],n[ i ] ); 
      fputs( ts, fh ); 

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

   fclose( fh ); 
} 

Buy = 0;
 

mastermind007

Well-Known Member
dell and sr114

Far better way to extract the data from Ami into text file is using explorer instead of scanner.

Scanner forces you into separate file and you have to change code if you have to change interval whereas with explorer, you can extract entire data in one file (or split using Filter); can control start and end dates; can control Interval (Daily, Weekly or Intraday (tick, minute, 5 min, 1 hour,,, whatever...))

Once the explorer is completed, either cut-paste data from results pane into excel or use File-> Save As to save explored data as CSV.

Code:
//@@mastermind007@@traderji.com@@
Filter = True;
Buy = True;
SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "Ticker"); // Comment this line if Ticker repeats
AddColumn( DateTime(), "Date", formatDateTime );
AddColumn(Open, "Open");
AddColumn(High, "High");
AddColumn(Low, "Low");
AddColumn(Close, "Close");
AddColumn(Volume, "Volume");
AddColumn(OpenInt, "OpenInt");
Enjoy!!
 

trash

Well-Known Member
dell and sr114

Scanner forces you into separate file and you have to change code if you have to change interval whereas with explorer, you can extract entire data in one file (or split using Filter); can control start and end dates; can control Interval (Daily, Weekly or Intraday (tick, minute, 5 min, 1 hour,,, whatever...))

Once the explorer is completed, either cut-paste data from results pane into excel or use File-> Save As to save explored data as CSV.

Code:
//@@mastermind007@@traderji.com@@
Filter = True;
Buy = True;
SetOption("NoDefaultColumns", True);
AddTextColumn(Name(), "Ticker"); // Comment this line if Ticker repeats
AddColumn( DateTime(), "Date", formatDateTime );
AddColumn(Open, "Open");
AddColumn(High, "High");
AddColumn(Low, "Low");
AddColumn(Close, "Close");
AddColumn(Volume, "Volume");
AddColumn(OpenInt, "OpenInt");
Enjoy!!

All due to respect but what you say is not true in the slightest. You can do all the same by auto-exporting to file. You just don't know how to do it. That doesn't mean what you say is true. Besides that you can auto-export using scan and explorer.

EDIT:

BTW this is the param window of my own "ultimate data exporter" that can export to dozens of different formats.



So I know what I'm talking about. And yes, you can set range and time frame via analysis setting.
 
Last edited:

amitrandive

Well-Known Member
Code:
TimeFrameSet(in5Minute);
ema5Min=EMA(C,20);
TimeFrameRestore();
EMA_5=TimeFrameExpand(ema5Min, in5Minute, mode=expandFirst);
Plot(EMA_5, "EMA_5_MIN", colorLime, styleThick);  	

TimeFrameSet(in15Minute);
ema15Min=EMA(C,20);
TimeFrameRestore();
EMA_15=TimeFrameExpand(ema15Min, in15Minute, mode=expandFirst);
Plot(EMA_15, "EMA_15_MIN", colorBlueGrey, styleThick);  	

TimeFrameSet(30*in1Minute);
ema30Min=EMA(C,20);
TimeFrameRestore();
EMA_30=TimeFrameExpand(ema30Min, 30*in1Minute, mode=expandFirst);
Plot(EMA_30, "EMA_30_MIN", colorRed, styleThick);  	

TimeFrameSet(inHourly);
ema60Min=EMA(C,20);
TimeFrameRestore();
EMA_60=TimeFrameExpand(ema60Min, inHourly, mode=expandFirst);
Plot(EMA_60, "EMA_60_MIN", colorBlue, styleThick);  	

P = Param("Points Difference", 5,0.5,25,0.5);
Filter = abs(EMA_5- EMA_15) < P AND abs(EMA_5- EMA_30) < P AND abs(EMA_5-EMA_60) < P AND 
         abs(EMA_15-EMA_30) < P AND abs(EMA_15-EMA_60) < P AND abs(EMA_30-EMA_60) < P;

AddColumn(EMA_5, "5minTF-20ema");
AddColumn(EMA_15,"15minTF-20ema");
AddColumn(EMA_30,"30minTF-20ema");
AddColumn(EMA_60,"60minTF-20ema");
Change Param to Adjust the gap, for nifty keep it 5-10 points for BNF can be 10-20 points etc . . .
Manoj

The idea behind this code is fantastic, but how can we use this.We need a filter for the results.What this code does is that is explores and gives a result for all the stocks involved.

A filter should narrow down the stocks.

Amit
 

manojborle

Well-Known Member
Manoj

The idea behind this code is fantastic, but how can we use this.We need a filter for the results.What this code does is that is explores and gives a result for all the stocks involved.

A filter should narrow down the stocks.

Amit
That is what my idea was, but it is not doing that.
 

mastermind007

Well-Known Member
All due to respect but what you say is not true in the slightest. You can do all the same by auto-exporting to file. You just don't know how to do it. That doesn't mean what you say is true. Besides that you can auto-export using scan and explorer.

EDIT:
BTW this is the param window of my own "ultimate data exporter" that can export to dozens of different formats.



So I know what I'm talking about. And yes, you can set range and time frame via analysis setting.
trash

LOL!!! Show me a person who can make a claim in topics that he does not know about ...

I don't know what offended you .... The comment I made was with respect to the default (most common) scanner code that was present before.

Since, you've not shown your AFL, all I can rely on is the param window. You've basically taken pains to create an elaborate scanner.
Kindly tell me the number of lines it takes. I manage to get most (if not all) same functionality in far fewer lines of Explorer.

I have no intent of criticizing your effort. Nevertheless, you prove the same thing that I asserted
 
Last edited:

mastermind007

Well-Known Member
Manoj

The idea behind this code is fantastic, but how can we use this.We need a filter for the results.What this code does is that is explores and gives a result for all the stocks involved.

A filter should narrow down the stocks.

Amit
Amit, What does it do then?
 

xsis

Active Member
if you open all codes for default indis in AB, they are BLUE in color. tht means their construct is not given in formula code!

for example - for OBV:
_SECTION_BEGIN("OBV");
Plot( OBV(), _DEFAULT_NAME(), ParamColor("Color", colorCycle ), ParamStyle("Style") );
_SECTION_END();

but what is OBV? if take a crude logic of it (correct me if i am wrng)-

if the closing price is above the prior close price then:
Current OBV = Previous OBV + Current Volume
If the closing price is below the prior close price then:
Current OBV = Previous OBV - Current Volume
If the closing prices equals the prior close price then:
Current OBV = Previous OBV (no change)

this means a crude code sahud have price + volume in it which is in end term as OBV the default code!

i want to know the construct of tht crude code using price and volume for OBV & MFI!

thks manoj for the logic behind it!
cud u pls put it in afl code!
no manoj! this code is available in AB itself and available to everyone. since they are the default indi, they are named as OBV and MFI in AB.
but i want to know the construct of OBV & MFI. its a couple of lines code for both. i misplaced it somewhere!
can anybody pls help?
 
Last edited:

Similar threads