Price Data Components
0
Views
0
Downloads
0
Favorites
Igrok
//+------------------------------------------------------------------+
//| Igrok.mq4 |
//| Andrei Andreev |
//| http://www.andand.ru |
//+------------------------------------------------------------------+
// BASED ON:
//+------------------------------------------------------------------+
//| ^X_Sensors.mq4 |
//| Version 2.0.1 |
//|------------------------------------------------------------------|
//| Copyright © 2007, Mr.WT, Senior Linux Hacker |
//| http://w-tiger.narod.ru/wk2/ |
//+------------------------------------------------------------------+
#property copyright "Andrei Andreev"
#property link "http://www.andand.ru"
#property indicator_chart_window
extern int ForDays=10;
extern int _Shift = 20;
extern color _R_Color = Crimson;
extern color _S_Color = Gold;
int _N_Time, _My_Period, ObjectId;
string OBJECT_PREFIX = "LEVELS";
//-------------------------------------------------------------------------------------------
int init() {
_My_Period=PERIOD_D1;
_N_Time = 0;
ObjectCreate("S1 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);
ObjectCreate("R1 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);
ObjectCreate("R2 line", OBJ_TREND, 0, Time[_Shift], 0, Time[0], 0);
ObjectSet("S1 line", OBJPROP_RAY, 1);
ObjectSet("S1 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("S1 line", OBJPROP_COLOR, _S_Color);
ObjectSet("R1 line", OBJPROP_RAY, 1);
ObjectSet("R1 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("R1 line", OBJPROP_COLOR, _R_Color);
ObjectSet("R2 line", OBJPROP_RAY, 1);
ObjectSet("R2 line", OBJPROP_STYLE, STYLE_DASH);
ObjectSet("R2 line", OBJPROP_COLOR, _R_Color);
ObjectCreate("R1 label", OBJ_TEXT, 0, Time[0], 0);
ObjectCreate("R2 label", OBJ_TEXT, 0, Time[0], 0);
ObjectCreate("S1 label", OBJ_TEXT, 0, Time[0], 0);
ObjectId = 0;
return(0);
}
//-------------------------------------------------------------------------------------------
int deinit() {
ObjectDelete("R1 label");
ObjectDelete("R1 line");
ObjectDelete("R2 label");
ObjectDelete("R2 line");
ObjectDelete("S1 label");
ObjectDelete("S1 line");
ObDeleteObjectsByPrefix(OBJECT_PREFIX);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start() {
if ( _N_Time == Time[0] ) return(0);
double open,close, high, low, koeff1, koeff2,P, R1, R2, S1;
double _rates[][6];
double AverageRange;
ArrayCopyRates(_rates, NULL, _My_Period);
int err = GetLastError();
if(err == 4066) {
Sleep(1000);
if(iClose(NULL, _My_Period, 0) != Close[0]) {
Sleep(1000);
return(0);
}
}
close = _rates[1][4];
high = _rates[0][3];
low = _rates[0][2];
open = _rates[0][1];
AverageRange=0;
for (int i=1;i<ForDays+1;i++)
{
AverageRange=AverageRange+(_rates[i][3]-_rates[i][2])/Point;
}
AverageRange=NormalizeDouble(AverageRange/ForDays,0);
Comment("\nÄèàïàçîí:",
"\nÑåãîäíÿ: ",(high-low)/Point,
"\nÂ÷åðà: ",(_rates[1][3]-_rates[1][2])/Point,
"\nÑðåäíèé: ",AverageRange," çà ",ForDays," äíåé");
S1 =open;
R1 =low;
R2 =high;
string s1,r1,r2;
s1 = DoubleToStr(S1, Digits);
r1 = DoubleToStr(R1, Digits);
r2 = DoubleToStr(R2, Digits);
//---- Pivot Lines
ObjectSetText("R1 label", " Min "+r1+"", 8, "Fixedsys", _R_Color);
ObjectSetText("R2 label", " Max "+r2+"", 8, "Fixedsys", _R_Color);
ObjectSetText("S1 label", " Open "+s1+"", 8, "Fixedsys", _S_Color);
ObjectMove("R1 label", 0, Time[0], R1);
ObjectMove("R2 label", 0, Time[0], R2);
ObjectMove("S1 label", 0, Time[0], S1);
ObjectMove("S1 line", 0, Time[_Shift], S1);
ObjectMove("S1 line", 1, Time[0], S1);
ObjectMove("R1 line", 0, Time[_Shift], R1);
ObjectMove("R1 line", 1, Time[0], R1);
ObjectMove("R2 line", 0, Time[_Shift], R2);
ObjectMove("R2 line", 1, Time[0], R2);
//====
_N_Time = Time[0];
//---- End Of Program
return(0);
}
//+------------------------------------------------------------------+
void ObDeleteObjectsByPrefix(string Prefix)
{
int L = StringLen(Prefix);
int i = 0;
while(i < ObjectsTotal())
{
string ObjName = ObjectName(i);
if(StringSubstr(ObjName, 0, L) != Prefix)
{
i++;
continue;
}
ObjectDelete(ObjName);
}
}
//-------------------------------------------------------------------------------------------
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---