-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tutorial14.mq4
53 lines (42 loc) · 1.69 KB
/
Tutorial14.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
//+------------------------------------------------------------------+
//| 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);
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));
}
}
}
//+------------------------------------------------------------------+