How to add some more indicators to export?

Hi All !

I found the useful code here:

Now I like to add some more indicators to export for each ticker, for example: MA20, MA100, MA200, even RSI(15) ...

fputs( "Date/Time,Open,High,Low,Close,Volume,MA20,MA50,MA100,MA200,RSI(15)\n", fh );

How to do it?

dt = DateTime();
ma20 = MA(C, 20);

// create folder for exporting purposes
fmkdir( "C:\\DataExport\\" );

// open file for writing
// file name depends on currently processed ticker
fh = fopen( "c:\\DataExport\\" + Name() + ".txt", "w" );

// proceed if file handle is correct
if ( fh )
{
    // write header line
   // fputs( "Ticker,Date/Time,Open,High,Low,Close,Volume,MA20\n", fh );
    fputs( "Date/Time,Open,High,Low,Close,Volume,MA20\n", fh );

    // iterate through all the bars
    for ( i = 0; i < BarCount; i++ )
    {
        // write ticker name
        //fputs( Name() + "," , fh );

        // write date/time information
        dtstr = DateTimeFormat( "%Y%m%d %H:%M,", dt[i] );
        //write quotations and go to the next line
        qs = StrFormat( "%g,%g,%g,%g,%g,%g\n", O[ i ], H[ i ], L[ i ], C[ i ], V[ i ], ma20[ i ] );
   
        fputs( dtstr + qs, fh );
    }
    // close file handle
    fclose( fh );
}
 
// line required by SCAN option
Buy = 0;
2 Likes

Many thanks and Welcom back FxShart!

Yes thìs is the Solution.