Scripts: Balance Graph HTML - page 2

 
amrali:

This might be shorter and faster

Yes, it is shorter. But has no possibility of further modification. For example, if you need to get graphs of profits, commissions, turnover, etc.


#define OP_BALANCE 6
#define OP_CREDIT  7
 
fxsaber, can I use the animated gif from your post
 
amrali:
fxsaber, can I use the animated gif from your post

Of course!

 
amrali:

Where can I generate various variants of the Graph.txt file?


<script src="exdat.txt" type="text/javascript"></script>

How to include data from exdat.txt file in final html file?

 

This method does not work. Therefore, I wrote a universal converter.


void ChangeString( string &Str )
{
  StringReplace(Str, "\\", "\\\\");
  StringReplace(Str, "\"", "\\\"");
  
  Str = "\"" + Str + "\\r\\n\" + " + "\n";
  
  return;
}

bool TextFileToMQH( const string FileNameIn, const string FileNameOut )
{
  const int handleIn = FileOpen(FileNameIn, FILE_READ | FILE_TXT | FILE_ANSI);
  bool Res = (handleIn != INVALID_HANDLE);

  if (Res)  
  {
    const int handleOut = FileOpen(FileNameOut, FILE_WRITE | FILE_TXT | FILE_ANSI);
    
    if (Res = (handleOut != INVALID_HANDLE))
    {
      FileWriteString(handleOut, "string StrMQH = \n");
      
      while (!FileIsEnding(handleIn))
      {
        string Str = FileReadString(handleIn);
  
        ChangeString(Str);
        FileWriteString(handleOut, Str);
      }

      FileWriteString(handleOut, "NULL;\n");
  
      FileClose(handleOut);            
    }
    
    FileClose(handleIn);
  }
  
  return(Res);
}

void OnStart()
{
  TextFileToMQH("Graph.txt", "Graph.mqh");
}


Now you can include the file in the source code

#include <..\Files\Graph.mqh>
 
amrali:

I pasted your HTML code into my library.

 
fxsaber:

I pasted your HTML code into my library.

No problem 
 
fxsaber:
Excellent work 
 
Great work! A pity that balance graphs aren't included by default in MT5.