-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathPip Value Calculator.mq4
107 lines (96 loc) · 4.16 KB
/
Pip Value Calculator.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#property copyright "ForexNew.org Opensource"
#property link "https://forexnew.org/"
#property version "1.10"
#property description "Pip Value Calculator For MetaTrader 4"
#property strict
#property indicator_chart_window
// Input parameters //
extern double Lot_Size=1.00; // Default Lot Size
extern int Text_Size=9; // Text Size
extern int decimal=2; //Decimal
extern color Text_Color=MintCream; // Text Color
extern color Panel_Color=SteelBlue; // Panel Color
string Font_Setting="Arial Black";
double point;
// Check symbol digits //
int OnInit()
{
point=Point;
if((Digits==3) || (Digits==5))
{
point*=10;
}
return(INIT_SUCCEEDED);
}
// Calculation function, Reference: https://www.mql5.com/en/docs/event_handlers/oncalculate //
int OnCalculate(const int rates_total,
const int prev_calculated,
const datetime &time[],
const double &open[],
const double &close[],
const double &high[],
const double &low[],
const long &volume[],
const long &tick_volume[],
const int &spread[])
{
string Account_Currency=AccountInfoString(ACCOUNT_CURRENCY);
double PipValue_Total=((((MarketInfo(Symbol(),MODE_TICKVALUE)*point)/MarketInfo(Symbol(),MODE_TICKSIZE))*Lot_Size));
// Create panel and text Label on the screen //
ObjectCreate("Main_Panel",OBJ_RECTANGLE_LABEL,0,0,0,0,0,0);
ObjectSet("Main_Panel",OBJPROP_BGCOLOR,Panel_Color);
ObjectSet("Main_Panel",OBJPROP_CORNER,0);
ObjectSet("Main_Panel",OBJPROP_BACK,true);
ObjectSet("Main_Panel",OBJPROP_XDISTANCE,10);
ObjectSet("Main_Panel",OBJPROP_YDISTANCE,20);
ObjectSet("Main_Panel",OBJPROP_XSIZE,240);
ObjectSet("Main_Panel",OBJPROP_YSIZE,95);
ObjectSet("Main_Panel", OBJPROP_SELECTABLE, false);
ObjectSet("Main_Panel", OBJPROP_HIDDEN, true);
ObjectCreate("Label_1", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Label_1","- Symbol : " + Symbol(),Text_Size,Font_Setting, Text_Color);
ObjectSet("Label_1", OBJPROP_CORNER, 0);
ObjectSet("Label_1", OBJPROP_XDISTANCE, 20);
ObjectSet("Label_1", OBJPROP_YDISTANCE, 27);
ObjectSet("Label_1", OBJPROP_SELECTABLE, false);
ObjectSet("Label_1", OBJPROP_HIDDEN, true);
ObjectCreate("Label_2", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Label_2","- Account Currency : " + Account_Currency,Text_Size,Font_Setting, Text_Color);
ObjectSet("Label_2", OBJPROP_CORNER, 0);
ObjectSet("Label_2", OBJPROP_XDISTANCE, 20);
ObjectSet("Label_2", OBJPROP_YDISTANCE, 47);
ObjectSet("Label_2", OBJPROP_SELECTABLE, false);
ObjectSet("Label_2", OBJPROP_HIDDEN, true);
ObjectCreate("Label_3", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Label_3","- Pip Value (one point) : " + DoubleToStr(PipValue_Total/10,decimal),Text_Size,Font_Setting, Text_Color);
ObjectSet("Label_3", OBJPROP_CORNER, 0);
ObjectSet("Label_3", OBJPROP_XDISTANCE, 20);
ObjectSet("Label_3", OBJPROP_YDISTANCE, 67);
ObjectSet("Label_3", OBJPROP_SELECTABLE, false);
ObjectSet("Label_3", OBJPROP_HIDDEN, true);
ObjectCreate("Label_4", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Label_4","- Pip Value (one pip) : " + DoubleToStr(PipValue_Total,decimal),Text_Size,Font_Setting, Text_Color);
ObjectSet("Label_4", OBJPROP_CORNER, 0);
ObjectSet("Label_4", OBJPROP_XDISTANCE, 20);
ObjectSet("Label_4", OBJPROP_YDISTANCE, 87);
ObjectSet("Label_4", OBJPROP_SELECTABLE, false);
ObjectSet("Label_4", OBJPROP_HIDDEN, true);
ObjectCreate("Label_5", OBJ_LABEL, 0, 0, 0);
ObjectSetText("Label_5","Copyright: ForexNew.org - Free Opensource",9, "Arial", DeepSkyBlue);
ObjectSet("Label_5", OBJPROP_CORNER, 2);
ObjectSet("Label_5", OBJPROP_XDISTANCE, 10);
ObjectSet("Label_5", OBJPROP_YDISTANCE, 10);
ObjectSet("Label_5", OBJPROP_SELECTABLE, false);
ObjectSet("Label_5", OBJPROP_HIDDEN, true);
return(rates_total);
}
// Delete panel and text label when removing the indicator //
void OnDeinit(const int reason)
{
ObjectsDeleteAll(0,"Main_Panel");
ObjectsDeleteAll(0,"Label_1");
ObjectsDeleteAll(0,"Label_2");
ObjectsDeleteAll(0,"Label_3");
ObjectsDeleteAll(0,"Label_4");
ObjectsDeleteAll(0,"Label_5");
}