Plot Candle From CSV?

Hi,

I am trying to plot candles from csv data, can anyone please help me fix this code?

file = SavedPath + Name() + "_" + ".csv"; 

//
fh = fopen( file, "r" );
lines = 500;
    ox = Null;
    hx = Null;
    lx = Null;
    cx = Null;
//
if( fh )
 {
 for ( i = 0 ; i < lines ; i ++ )
 {
     while( ! feof( fh ) )
     {
         line = fgets(fh);
         
         	ox [i] = StrExtract( line, 0 );
            hx [i] = StrExtract( line, 1 );
            lx [i] = StrExtract( line, 2 );
            cx [i] = StrExtract( line, 3 );

     }
     //
}
     fclose( fh );
 }
 
 else
 {
     Error( "ERROR: file can not be open" );
 }

PlotOHLC( ox, hx, lx, cx, "Pattern", colorBlack, styleCandle | styleOwnScale | styleNoLabel | styleNoTitle, 0, 0, 1, 1 ); 

Here is the contents of the csv file.
filelist

Thanks.

1 Like

Use Import Ascii or a CSV data plugin

Hi

What I mean is plotting the csv data to the chart that I open. I want to plot the candles not adding data to the database. I want to plot the pattern of prices from the csv data.

If I understand your reply correctly, by using import Ascii or a CSV data plugin, it means I will add data to the database.

Thanks.

Correct.
You create a CSVsymbol or update it's data with import ascii. After,
you open the real symbol and USE FOREIGN to access your CSVsymbol and plot both.

If adding new data is a big concern you may consider a solution similar to this http://www.amibroker.com/kb/2014/09/30/gen-backtest-from-a-file/

Hi

I am trying to achieve something like this:
somethinglikethis

But this is through csv data, for example, if I press plot data from csv in the parameter window, it will open the csv and then plot the data to the chart that I open.

The link that you provided is where I got the idea from, but I can not seem to be able to plot the candles to the chart, it only get the last data not all data from csv. If you can, please check the code.

Thanks.

A chart must have a amibroker symbol associated with it.

@newbietrader
Search “SparseCompress” example by @Tomasz @fxshrat @awilson may be that help…

Hi

Yes, SparseCompress and PlotForeign works.

Thank you all.