Plot Candle From CSV?



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 );
     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.



Use Import Ascii or a CSV data plugin



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.



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



I am trying to achieve something like this:

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.



A chart must have a amibroker symbol associated with it.


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



Yes, SparseCompress and PlotForeign works.

Thank you all.