-
Notifications
You must be signed in to change notification settings - Fork 0
/
Spread indicator.mq4
72 lines (64 loc) · 2.53 KB
/
Spread indicator.mq4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#property copyright "ForexNew.org Opensource"
#property link "https://forexnew.org/"
#property version "1.0"
#property description "- Spread Indicator"
#property description "- Indicator for Metatrader 4"
#property strict
#property indicator_chart_window
extern int Text_Size=9; // Text Size
extern color Text_Color=MintCream; // Text Color
extern color Panel_Color=SteelBlue; // Panel Color
string Font_Setting="Arial Black";
extern int Panel_Width=150; // Panel Width
extern int Panel_Height=35; // Panel Height
extern int Position_X=20; // Position X
extern int Position_Y=60; // Position Y
int positionsetx=Position_X+12;
int positionsety=Position_Y+10;
int init()
{
Check_Spread();
return(INIT_SUCCEEDED);
}
int start()
{
Check_Spread();
return(INIT_SUCCEEDED);
}
void Check_Spread()
{
int spread = MarketInfo( _Symbol, MODE_SPREAD );
// Create panel and text Label on the screen //
ObjectCreate("Spread_Panel",OBJ_RECTANGLE_LABEL,0,0,0,0,0,0);
ObjectSet("Spread_Panel",OBJPROP_BGCOLOR,Panel_Color);
ObjectSet("Spread_Panel",OBJPROP_CORNER,0);
ObjectSet("Spread_Panel",OBJPROP_BACK,true);
ObjectSet("Spread_Panel",OBJPROP_XDISTANCE,Position_X);
ObjectSet("Spread_Panel",OBJPROP_YDISTANCE,Position_Y);
ObjectSet("Spread_Panel",OBJPROP_XSIZE,Panel_Width);
ObjectSet("Spread_Panel",OBJPROP_YSIZE,Panel_Height);
ObjectSet("Spread_Panel", OBJPROP_SELECTABLE, false);
ObjectSet("Spread_Panel", OBJPROP_HIDDEN, true);
ObjectCreate("Spread_Label", OBJ_LABEL, 0, 0, 0);
ObjectSet("Spread_Label", OBJPROP_CORNER, 0);
ObjectSet("Spread_Label", OBJPROP_XDISTANCE, positionsetx);
ObjectSet("Spread_Label", OBJPROP_YDISTANCE, positionsety);
ObjectSetText("Spread_Label", "Spread = "+spread+" Points", Text_Size, Font_Setting, Text_Color);
ObjectSet("Spread_Label", OBJPROP_SELECTABLE, false);
ObjectSet("Spread_Label", OBJPROP_HIDDEN, true);
ObjectCreate("Custom_Label", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Custom_Label","Copyright: ForexNew.org - Free Opensource",9, "Arial", DeepSkyBlue);
ObjectSet("Custom_Label", OBJPROP_CORNER, 2);
ObjectSet("Custom_Label", OBJPROP_XDISTANCE, 10);
ObjectSet("Custom_Label", OBJPROP_YDISTANCE, 10);
ObjectSet("Custom_Label", OBJPROP_SELECTABLE, false);
ObjectSet("Custom_Label", OBJPROP_HIDDEN, true);
WindowRedraw();
}
// Delete panel and text label when removing the indicator //
void OnDeinit(const int reason)
{
ObjectsDeleteAll(0,"Spread_Panel");
ObjectsDeleteAll(0,"Spread_Label");
ObjectsDeleteAll(0,"Custom_Label");
}