-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_Tail_Stops.mq4
56 lines (44 loc) · 1.81 KB
/
3_Tail_Stops.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
//+------------------------------------------------------------------+
//| Tail_Stops.mq4 |
//| Copyright 2016, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property strict
#property script_show_inputs
//--- input parameters
input string vCurrencyPair;
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
int total= OrdersTotal();
string curr = vCurrencyPair;
curr = StringToUpper( curr ) ;
for(int i=total-1;i>=0;i--)
{
int ticket;
ticket = OrderSelect(i,SELECT_BY_POS);
int type=OrderType();
string symbol=OrderSymbol();
symbol = StringToUpper(symbol);
if( curr == symbol)
continue;
double Step = StrToDouble(OrderComment());
Print( StrToDouble(OrderComment()));
if( Step > 0 ) {
switch(OrderType()){
case OP_BUYSTOP: case OP_BUY: case OP_BUYLIMIT:
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss()+Step, OrderTakeProfit(),NULL, Yellow);
break;
case OP_SELLLIMIT: case OP_SELL: case OP_SELLSTOP:
OrderModify(OrderTicket(), OrderOpenPrice(), OrderStopLoss()-Step, OrderTakeProfit(),NULL, Yellow);
break;
}
}
}
WindowRedraw();
}