-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTutorial16.mq4
61 lines (45 loc) · 1.88 KB
/
Tutorial16.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
//+------------------------------------------------------------------+
//| Tutorial16.mq5 |
//| Copyright 2019, GeneticTrading |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, GeneticTrading"
#property link "https://www.mql5.com"
#property version "1.00"
#property script_show_inputs
#property strict
extern int TakeProfit = 10;
extern int StopLoss = 10;
void OnStart()
{
//--- FAil safe programing
double TakeProfitLevel;
double StopLossLevel;
TakeProfitLevel = Bid+TakeProfit* Point;
StopLossLevel = Bid-StopLoss*Point;
/*
The order send function return ticked if it works
and return a -1 if it does not work
*/
int Ticket= OrderSend("EURUSD", OP_BUY , 1.0, Ask, 10, StopLossLevel, TakeProfitLevel," my frist order with mt4" );
if( Ticket <0){
Alert(" Ticket was not Created ");
}
else{
Alert(" Your Ticket is " , Ticket);
Sleep(5000);
Alert(" getting order information");
bool res = OrderSelect(Ticket,SELECT_BY_TICKET);
if( res == True){
Alert( " Information about the order # :", Ticket );
Alert(" Order Symbol :", OrderSymbol());
Alert( " Order Type", OrderType());
Alert(" Order Comment",OrderComment());
Alert(" Order Profit", OrderProfit());
} else
{
Alert(" Could Not Find order" , Ticket);
}
}
}
//+------------------------------------------------------------------+