Convert: easyLanguage to MT5

 

Hello guys

This is a Tradestation easylanguage indicator that creates and update ascii data file in real time as new data appears on the Tradestation chart. Dynamic trader charting software then reads and charts these ascii file real time. Can someone help me translate this to mt5 indicator

Thanks


Vars:   Directory("D:\TSDATA\"),
                Interval(" "),
                FileName(""),
                x(0),
                thisTickType(0),
                ThisVolume(0),
                Count(0),
                IntrabarPersist LastDate(0),
                IntrabarPersist LastTime(0),
                barTime(0), {will force 0 if daily, weekly, or monthly}
                fname("");

definedllfunc:  "D:\tsdata\TS.DLL",int,"SendData",float,lpstr,lpstr,lpstr,float,float,float,float,float,float,float,float;


ThisVolume = Volume;
if barnumber = 1 then
begin
        if DataCompression = 0 then Interval = NumToStr(Highest(upticks + downticks,5),0);
        if DataCompression = 1 then Interval = NumToStr(BarInterval,0);
        if DataCompression = 2 then Interval = "Daily";
        if DataCompression = 3 then Interval = "Weekly";
        if DataCompression = 4 then Interval = "Monthly";

    fname = getsymbolname + "_"+Interval+"."; {name & extension only}

        if DataCompression = 0 then fname = fname + "dtt";
        if DataCompression = 1 then fname = fname + "dti";
        if DataCompression = 2 then fname = fname + "dtd";
        if DataCompression = 3 then fname = fname + "dtw";
        if DataCompression = 4 then fname = fname + "dtm";

    FileName = Directory + fname;

        Input: cf(4);

        FileDelete(FileName);
        FileAppend(FileName,"cf= " + NumToStr(CF,0) + newline);
        if DataCompression = 0 then FileAppend(FileName,"ticks= " + Interval + NewLine);
        if DataCompression = 1 then FileAppend(FileName,"min= " + Interval + NewLine);
        if DataCompression > 1 then FileAppend(FileName, LeftStr(Interval,1) + NewLine);
        FileAppend(FileName,"DATE TIME OPEN HIGH LOW CLOSE VOLUME" + NEWLINE);

        for x = MaxBarsBack downto 1
        begin
                ThisVolume = iff(DataCompression =0,Upticks[x] + DownTicks[x],Volume[x]);

                if DataCompression >=2 then
                        barTime = 0
                else
                        barTime = Time[x];

                fileappend(FileName,numtostr(date[x],0) + " " + numtostr(barTime,0) + " " +
                        numtostr(open[x],4) + " " + numtostr(high[x],4) + " " + numtostr(low[x],4) + " " + numtostr(close[x],4) + "  " +
                        numtostr(ThisVolume,0) + newline);

                LastDate = Date;  {Date & Time of last whole bar stored in file}
                LastTime = barTime;     
        end;
end;

if DataCompression >=2 then
        barTime = 0
else
        barTime = Time;


thisTickType = BarStatus(1);  { 0  -> Open tick of bar (only for "Open Next Bar order" strategies
                                                                1  -> tick within bar
                                                                2  -> closing tick of bar
                                                                -1 -> error
                                                           }
                                                
        if thisTickType = 2 then {closing tick of bar}
        begin   {Last Tick Of Bar, append new line to text file}        
                fileappend(FileName,numtostr(date,0) + " " + numtostr(barTime,0) + " " +
                        numtostr(open,4) + " " + numtostr(high,4) + " " + numtostr(low,4) + " " + numtostr(close,4) + " " +
                        numtostr(ThisVolume,0) + newline);
        end;


if LastBarOnChart then 
        begin
                if (thisTickType >= 1)  then    
                          value1 = SendData(thisTickType, GetSymbolName, Interval, fname, Date, barTime, Open, High, Low, Close, ThisVolume, OpenInt);
        end;

LastDate = Date;
LastTime = barTime;
 

Search for csv files  and find that is colsest to you ideas and change it according to your needs.

If you place the cursor on e.g. FileOpen and press F1 you are directed to the reference of this function and there you find examples too.