This forum is in read-only mode now. You may discuss your questions on forums of MQL4.community and MQL5.community

MT4 Trailing Stop (5 pips and 10 pips)


Back to topics list
avatar
22
TheWolf 2005.07.17 13:47 
Does anyone know how I can get trailing stops with 5 and 10 pips? I heard there's an expert for it, but I can't find it. Thanks in advance
avatar
240
MartinCooney 2005.07.17 14:11 
Don't you just right click on the order, select Trailing Stop, choose Custom and type in the value you require ?
avatar
22
TheWolf 2005.07.17 15:27 
Don't you just right click on the order, select Trailing Stop, choose Custom and type in the value you require ?


Thanks for your reply. I can't choose e.g. 10 pips as it says that the minimal level is 15 pips.

avatar
120
hdb 2005.07.18 02:49 
this is imho an annoying 'feature' of MT4... training stops cannot be less than 15.. i really dont know why. anyway, here is some code i got from this forum... somewhere.. i have not changed it nor tested it.

//+------------------------------------------------------------------+
//|                                              Trailing Stop 5.mq4 |
//|                      Copyright © 2004, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2004, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
extern double TakeProfit = 0;
extern double StopLoss = 15;
extern double Lots = 1;
extern double TrailingStop = 5;

int init()
  {
//---- TODO: Add your code here.
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int pos3pre = 1;
int pos4cur = 0;
int cnt = 0;
int openpozprice = 0;
int mode = 0;
int deinit()
  {
//---- TODO: Add your code here.
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  for (int i = 0; i < OrdersTotal(); i++) {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);

      if (OrderType() == OP_BUY) {
         //if (Bid > (OrderValue(cnt,VAL_OPENPRICE) + TrailingStop * Point)) {
         //   OrderClose(OrderTicket(), OrderLots(), Bid, 3, Violet);
         //   break;
         //}
         if (Bid - OrderOpenPrice() > TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) {
            if (OrderStopLoss() < Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) {
               OrderModify(OrderTicket(), OrderOpenPrice(), Bid - TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(), Red);
            }
         }
      } else if (OrderType() == OP_SELL) {
         if (OrderOpenPrice() - Ask > TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) {
            if ((OrderStopLoss() > Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT)) || 
                  (OrderStopLoss() == 0)) {
               OrderModify(OrderTicket(), OrderOpenPrice(),
                  Ask + TrailingStop * MarketInfo(OrderSymbol(), MODE_POINT), OrderTakeProfit(), Red);
            }
         }
      }
	}

//---- TODO: Add your code here.
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

avatar
22
TheWolf 2005.07.18 03:54 
Thanks alot hdb. Just one more thing, what does the 'lots' variable do? Argh I must learn MT4! hehe
avatar
120
hdb 2005.07.18 17:20 
it does nothing...


avatar
41
DrZogg 2005.07.19 14:06 
I have in the past run trailing stops of ten or less, obviously from my own expert, but with a minimum spread of 3 it doesn't really make sense.

I'd say 15 is the minimum you want to run at....
avatar
22
TheWolf 2005.07.19 17:18 
I have in the past run trailing stops of ten or less, obviously from my own expert, but with a minimum spread of 3 it doesn't really make sense.

I'd say 15 is the minimum you want to run at....


Anychance you could send me that expert? :)
avatar
41
DrZogg 2005.07.19 17:26 
Sorry.....no can do...
avatar
14
Alexantry 2005.07.19 17:35 
The code ,why I can't attach to a chart?
Back to topics list  
Download MetaTrader 5 (450 Kb, web installer) — a new terminal for financial markets