-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTutorial15.mq4
70 lines (53 loc) · 2.18 KB
/
Tutorial15.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
//+------------------------------------------------------------------+
//| Tutorial13.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);
Alert(" modifying Order ......");
Sleep(5000);
bool res = OrderModify(Ticket , 0, Bid - 5*StopLoss * Point, Bid +5*TakeProfit* Point,0);
if ( res == false){
Alert(" Could not modify Order");
}
else{
Alert(" Sucessfully Modified Order" + string(Ticket));
}
/*
delete order function
bool res = OrderClose(Ticket, 1.0,Bid, 10);
/*
the order sed return false if it cant cole on order and return true if it can
if( res == False){
Alert(" could not close the Order" + string(Ticket));
}
else{
Alert(" Sucessfully closed close the Order" + string(Ticket));
}
*/
}
}
//+------------------------------------------------------------------+