nImage2Graph

Author: Copyright � 2010, FXMaster.de
Miscellaneous
Uses files from the file systemIt reads information from a file
0 Views
0 Downloads
0 Favorites
nImage2Graph
//+------------------------------------------------------------------+
//|                                                  Image2Graph.mq4 |
//|                                    Copyright © 2010, FXMaster.de |
//|                      êîä - Àëåêñåé Ñåðãååâ (profy.mql@gmail.com) |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2010, FXMaster.de"
#property link      "mailto: profy.mql@gmail.com | Àëåêñåé Ñåðãååâ"
#include <stderror.mqh>
#include <stdlib.mqh>

#property show_inputs

extern string image="wom_black.txt";
extern double pixHigh=20;

//------------------------------------------------------------------ start
int start()
{
	int h=FileOpen(image, FILE_READ|FILE_CSV); FileSeek(h, 0, SEEK_SET);
	string st; int ch; color clr=0; int R, G, B, i, n; 
	int x=0, dx=1, x0=550; 
	double y=0, dy=pixHigh*Point, y0=WindowPriceMax()-2*dy;
	
	while (!FileIsEnding(h))
	{
		st=FileReadString(h); n=StringLen(st); x=0; i=0;
		ch=StringGetChar(st, 0); if (ch!='@') y--;
		while (i<n)
		{
			ch=StringGetChar(st, i);
			if (ch=='#')
			{
				R=GetNum(StringSubstr(st, i+1, 2)); G=GetNum(StringSubstr(st, i+3, 2));
				B=GetNum(StringSubstr(st, i+5, 2)); clr=RGB(R, G, B); i+=6;
			}
			if (ch=='|') { x--; SetRect("line"+x+"."+DoubleToStr(y, 0), 0, Time[x0+x*dx], y0+y*dy, Time[x0+(x+1)*dx], y0+(y+1)*dy, clr, n+" "+i); }
			i++;
		}
	}
	Print(x);
	FileClose(h);
}
//------------------------------------------------------------------ GetNum
int GetNum(string st)
{
	int c[256];
	c['0']=0;	c['1']=1;	c['2']=2;	c['3']=3;	c['4']=4;	c['5']=5;	c['6']=6;	c['7']=7;	c['8']=8;	c['9']=9;
	c['a']=10;	c['b']=11;	c['c']=12;	c['d']=13;	c['e']=14;	c['f']=15;
	c['A']=10;	c['B']=11;	c['C']=12;	c['D']=13;	c['E']=14;	c['F']=15;
	int c1=StringGetChar(st, 0); 
	int c2=StringGetChar(st, 1);
	return(c[c1]*16+c[c2]);
}
//------------------------------------------------------------------ SetRect
void SetRect(string name, int wnd, datetime dt1, double pr1, datetime dt2, double pr2, color clr, string st)
{
	ObjectCreate(name, OBJ_RECTANGLE, wnd, 0, 0);
	ObjectSet(name, OBJPROP_TIME1, dt1); ObjectSet(name, OBJPROP_PRICE1, pr1);
	ObjectSet(name, OBJPROP_TIME2, dt2); ObjectSet(name, OBJPROP_PRICE2, pr2);
	ObjectSet(name, OBJPROP_COLOR, clr); ObjectSetText(name, st); 
//	ObjectSet(name, OBJPROP_BACK, true);
}

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---