AFX_Trailing

ATR Trailing Stop Management

PipDefender                                                                 Cerca nel sito         


  ...one EA to rule them all... >   
 PipDefender v1.333 user manual  
                                                                                                                                                    (translated by Alessandro Capponi) 

 PipDefender is an Order Management Expert Advisor (EA) designed for Metatrader v4. It implements a range of orders' handling 
 techniques for both orders opened manually or by others EA. PipDefender never ever opens orders but it takes care of manage them, 
 trying to maximize profits and reduce losses. In order to use PipDefender profitably it' s necessary to be familiar with terms like stop 
 level, slippage, magic number. If you're not sure about their meaningyou should clarify your doubts before using this program. 

  
 Operating modes 
  

         Safe Mode 

 This is the mode to manage the closure of orders that are opens from "too much" time (user can define after how long is "too much") 

         Stealth mode 

 This is the mode to hide the real stop loss value from your broker 

         Profit management mode 

 This is the core of the EA functionality: the Profit Management Mode is always active, if you want to disable it you have to disable 
 PipDefender or remove it from its chart 

  

  

      1.0 Safe mode 

  
 Safe Mode allows to set PipDefender in a way it can automatically close the orders that are open from more than a certain number of 
 hours. In particular after MAX_HOURS_WARNING hours PipDefender will try to close the order with a minimum profit or even with a 
 break-even. After MAX_HOURS_ALARM hours PipDefender will try to close the order with a maximum loss of SAFE_LOSS pips. 
  










         SAFE_MODE [true|false] : enable or disable the Safe Mode.  
         MAX_HOURS_WARNING [number of hours > 0] : After this number of hours (counted from the order opening time) the safe 
           mode is activated under the warning mode.  
         MAX_HOURS_ALARM [number of hours > MAX_HOURS_WARNING] : After this number of hours (counted from the order 
           opening time) the safe mode is activated under the warning mode.  
         SAFE_LOSS [number of pips> 0] : this value is the maximum loss, express in pips, that you're disposed to accept in case an order 
           is closed under the Safe Alarm Mode. 

  


         2.0 Stealth Mode 

 The Stealth Mode modifies the Take Profit and the Stop Loss levels of the order, setting them on values outside the normal floating 
 market scale. The Stop Loss is managed by two parameters: the first one represent the value at wich PipDefender will close the order 
 (TRUE_SL) the second one is the "false" level that is set to deceive too curious brokers (FALSE_SL). It's important to underline that 
 TRUE_SL is a virtual stop loss level (memorized into PipDefender) whereas FAKE_SL it's a real and effective stop loss. In case of PC or 
 server malfuction that prejudice PipDefender from working and monitor your orders what count is the FAKE_SL because it's the only 
 value set onyour broker' server. Instead, if PipDefender can normally work the FAKE_SL could never be reached because after an order 
 reach the TRUE_SL value PipDefender close it. The Stealth Mode is usefull to hide your order strategy from the broker, in fact the 
 TRUE_SL value is not visible to your broker (FAKE_SL is fully visible). Take Profit management need its own explanation: this value 
 doesn't have a practical meaning while the order is into loss, as from the moment that the order start to be profitable PipDefender 
 management come up and the take profit value still lose its meaning and importance (because the profits are guaranteed based on the 
 stop loss value modifies). Consequently, by enabling the Stealth Mode, the Take Profit is automatically set at 100 pips from the opening 
 price and modified time after time if and when necessary... so you can completely forget about this value! 
         STEALTH_MODE [true|false] : enable or disable the stealth mode  
         TRUE_SL [number of pips>= 0] :is the Stop Loss, express in pips, for the managed orders. PipDefender will close all the orders 
           that are losing TRUE_SL or more pips  
         FAKE_SL [number of pips > TRUE_SL] : it represent the number, express in pips, really set on your broker' server, it is the "fake" 
           level, readable from your broker 

  



      3.0 Profit management mode  

 The Profit Management is the main order management modality. The Profit Management uses a trailing tecnique that is set by the three 
 parameters TRAILING_START, TRAILING_STOP and TRAILING_STEP. As soon as possible this modality start to sets limits lower than the 
 actual order gain (so it sets the profit stop losses) and as the the order's profit grow this profit stop losses are consequently modified. If 
 the profit starts to decrease the last set stop loss guarantees a certain number of pips that represent the mimimum secure profit, the so-
 called safe profit. 
  

         TRAILING_START [number of pips >= 1] : is the mimimum profit, express in pips, that you intend to achieve with the order. The 
           first profit stop loss will be set as soos as will be possible to guarantee at least the indicated pips.  
         TRAILING_STOP [number of pips >=STOP LEVEL] : pips from the current profit that you intend to use to absorb potential 
           retracements. Please note: in the eventuality that the Kamikaze mode is active the limitation on this parameter becomes less 
           restrictive, in particular TRAILING_STOP >= 1. Please consult the paragraph 3.2 for more details.  
         TRAILING_STEP [number of pips <= TRAILING_STOP] : minimum increment of the profit stop loss. Apart from particular 
           circumstances it's convenient to keep this value at his default setting that correspond to 1. 

  
 Example: 
  












                                                                                                                                                                                                                  

 TRAILING_START = 10 pip 
 In this case you want to gain at least 10 pips: the first profit stop loss will be set just after it will be able to guarantee 10 pips. 
 TRAILING_STOP =7 pip 
 This means you're disposed to use 7 pips to follow price's oscillations. This paramenter indicates the distance between the current price 
 and the value at wich will be set the profit stop losses, in particular the first profit stop loss (shown in in the picture as SL1) will be set 
 when the order will gain at least TRAILING_START + TRAILING_STOP pips (10+7 = 17 pips) 
 TRAILING_STEP = 2 pip 
 This means that after setting the first profit stop loss at 10 pips, the followings (shown as SL2 and SL3 in the picture) stop losses will be 
 set every time the order gain 2 more pips. If the profit goes to 19 then the stop loss will be set at 12, if the profit goes till 21 the stop loss 
 will be set at 14 ecc... 
  

  

      3.1 Greedy mode 

 The Greedy Mode is a supplementary modality that is applied to the Profit Management. Once this modality has been activated then 
 PipDefender will start to dinamically modify the trailing stop by reducing or increasing it (till a maximum value set by the TRAILING_STOP 
 parameter) every time the order price stand still for too much time or if it starts to violently move in the direction is favorable to us. The 
 idea behind this mode is that if the price start to stand still for too many seconds probably a stronger movement in one direction is going 
 to happen. The direction favorable to us, if followed with jerks movements (as in case of spikes greaters than the actual trailing stop) 
 cause a trailing stop increase, vice versa a movement in the direction contrary to us will result in a order closure, maybe with several pips 
 of income loss. In order to prevent this second case, if the price doesn't move, PipDefender will try to gradually get closer to the actual 
 price, so it will accumulate additional profit's pips. This will problably result in the order closure in case of little retracements but at the 
 same time it can guarantee major proficts in case of sudden spikes. Once into the Greedy mode then PipDefender will ignore the 
 parameters TRAILING_STOP and TRAILING_STEP: in fact the first one will be dinamically varied while the second will be set at 1 pip fixed 
 value. The Greedy mode is particularly usefull in case of manual orders of wide scope (orders with a take profit of 20 or more pips) 
 because it allows to take the additional profits that come from both sudden and fast spikes or from sluggish market conditions by 
 dinamically reducing the trailing stop . 

         GREEDY_MODE [true|false] : enable or disable the greedy mode.  
         GREEDY_SECS [1 <= number of seconds <= 60] : number of seconds during wich the price have to stand still so the dinamic 
           trailing stop reduction will start.  
         GREEDY_DECAY [ 10 <= percentuale <= 90] : Trailing stop lowering percentage.  

 Once the Greedy mode is activated you will see a note alongside of the order's ticket number, located into the informative panel where 
 are also shown all the gains and lossess of every monitored order. 
  
 Important note: the Greedy's Trailing Stops (GTS) are kept in memory by PipDefender and generally are differents for every order (that's the 
 reason why they are written on the UI next to the ticket number). If you reset the EA while is managing a list of orders with differents GTS from 
 the base trailing stop then you will reset also this Greedy's trailing stops. In fact if you change the timeframe or a parameter of the EA you will 
 cause a reset and because GTS parameters are keep in memory they will be reset to their base value. Despite this is not dangerous it's better 
 to keep it in mind.  
 Important note (2): if your broker has a zero stop level (if it's for example an STP or ECN broker) setting a profit stop loss at the minimum 
 possible distance from the actual price would imply the automatic order closure. In this case the Greedy mode will instead keep to consider 
 always 1 pip as the minimum distance between the actual order price and the profit's stop loss. This way it's very probable that the order will 
 close in consequence of a minimum retracement, but is equally probable to obtain further new profits in the opposite eventuality that the trend 
 keep its course. 
  


      3.2 Kamikaze mode 

 The Kamikaze Mode is another supplementary modality to the traditional Profit Management method, primarily developed to manage 
 scalping operations. Once the Kamikaze mode is activated PipDefender works just as it normally does with the only difference that when 
 it has to set a profit stop loss this value is not set, instead it's kept into the EA's memory. As soon as this virtual value is hit PipDefender 
 send the command to close the order. If the Kamikaze mode is active the stop level is replaced with a virtual stop loss that has a value 
 equal to 0.0 pips and pratically the TRAILING_STOP parameter could be reduced till just 1 pip, as in case of ECN brokers with zero stop 
 loss. 

         KAMIKAZE_MODE [true|false] : enable or disable the Kamikaze mode.  
         KAMIKAZE_PROTECTION [true|false] : enable or disable the additional protection that confine between a real stop loss and 
           a real take profit value the working interval of the kamikaze mode. 

 The main advantage deriving from the use of this mode is that the virtual stop loss don't has to respect the broker limits regarding the 
 stop level. Sure enough, once the Kamikaze mode is active the restriction on the parameter TRAILING_STOP is reduced, it goes from 
 TRAILING_STOP>=STOP LEVEL to a simpler TRAILING_STOP>=1. The main disadvantage that the Kamikaze mode involves is that once 
 an order touches his virtual stop loss the closure of the order is not 100% guaranteed, this depend from both our platform reactivity (PC 
 + Metatrader + Internet connection) and the reactivity of our broker's server. In the worst cases may happen that the order hits the real 
 stop loss value, because it wasn't possible to properly close the order once it hit the virtual stop loss... Not by chance this modality is 
 called Kamikaze! 
 The modality KAMIKAZE_PROTECTION = TRUE allow PipDefender to sets a real stop loss (about 10 pips lower than the last set kamikaze 
 virtual stop loss) and a real take profit (about 30 pips from the actual price) so that it guarantees, within the bounds of possibility, that in 
 case of Metatrader freeze because of Pc problems or a blackout or even a line problem you won't risk to transform potential profits 
 into losses. 
  
 Important note: if Kamikaze mode has the parameter KAMIKAZE_PROTECTION = FALSE then it never modifies the real take profit and 
 stop loss values of the orders it supervises. 
  
 Example: 
 Let's suppose we want to scalp on a pair that because of our broker policy has a 7.0 pips stop level. This stop level greatly limits the 
 operations of trailing-scalping because 7 pips as minimum distance between the current price and the profit stop loss are in general too 
 much for operations that has a profit target of 3/5 pips. By activating the Kamikaze mode the stop level goes to the virtual value of 0.0 
 pips, this way we can use the trailing settings for scalping. With the Kamikaze mode it's possible to scalp on "exotic" pairs like USDNOK or 
 USDDDK (on wich my broker has rispectively 50 and 30 pips of stop level!) 
 Important Note: Kamikaze mode can't help against spreads excessively wide, do not confuse the stop loss with the spread! 
  


  

      3.3Breakeven mode 

 The Breakeven mode is an additional operating modality that can work together with any of the previous modalities and the way it 
 works is very simple: as soon as the order is gaining more than BREAKEVEN_AFTER pips then a stop loss is placed at the entry price 
 (precisely a breakeven). Please note that the breakeven mode is activated only if doesn't exist a better stop loss already set. 

         BREAKEVEN_MODE [true|false] : enable or disable the Breakeven mode.  
         BREAKEVEN_AFTER [STOP LEVEL <= number of pips < TRAILING_START ] : number of profit's pips after wich the breakeven 
           start.  
         BREAKEVEN_CLOSE_PERCENT [0 <= percentage <= 100] : if possible at the moment of breakeven the order will be closed 
           for the indicated percentage 

 Please Note: the order's closing percentage is just indicative: PipDefender will try to close the order at the set percentage or at the legal 
 value immediately lower. If you want to close at 53% an order of 0.02 lots it won't be possible to exactly meet this percentace because 
 you can not close and order of 0.0106 lots but just an order of 0.01 lots. 
 Please note (2): PipDefender automatically calculates the correct dimension for partial orders closure also in relation with the minimum 
 dimensions of the orders imposed by your broker. If it's not possible to close the order PipDefender won't generate an error message, 
 instead it will write a warning line in the EA's log. This happen because it's not possible to know a priori not the possible dimension of the 
 orders you want to close neither the percentage you desire. Anyway, if the worst came to the worst the order is into breakeven and so you 
 won't suffer any loss. 
 Important note: before use partial orders closure please make sure your broker will support them. PipDefeder has no way to knows a 
 priori if the broker accepts or not partial orders closure. 
  


 4.0 Other parameters 
         CLOSE_SLIPPAGE [numerodi pip >= 0] : it's the amount of slippage, express in pips, used for the orders closure command. 
           Normally this value is set at half pip and it can increased according to your needs, just keep in mind that the greater the value of this 
           parameter is the more unfavourable can become an order closure in case of violent price oscillations.  
         PAUSE [true|false] : if set on true then PipDefender goes into pause and immediately stops monitoring orders. Because of the 
           critical functionalities of PipDifender since the version 1.23 the EA will be always launched in modality PAUSE = true.  
         EXCLUDE_MAGIC [comma separated list of magic numbers] : by default PipDefender monitors and manages all the buy and 
           sell orders of the cross on wich is activated (if it's active on the EURUSD chart, it will monitor and manage all the buy and sell 
           orders on EURUSD). In case you want to prevent PipDefender from managing orders opened by other EA's on the same cross you 
           just need to include the magic number of this EA's in the parameter EXCLUDE_MAGIC.  
         INCLUDE_MAGIC [comma separated list of magic numbers] : by default PipDefender monitors and manages all the buy and 
           sell orders of the cross on wich is activated (if it's active on the EURUSD chart, it will monitor and manage all the buy and sell 
           orders on EURUSD). In case you want PipDefender to manage just orders with specific magic numbers then you just need to insert 
           this numbers in the parameter INCLUDE_MAGIC.  
         EXCLUDE_TICKET [comma separated list of ticket numbers] :if you don't want to exclude entire categories of magic numbers 
           but just specific orders from PipDefender control you need to insert their ticket numbers into this list and so PipDefender will ignore 
           them as they wouldn't exist. 

 Example: 
 We have the Goofy EA on the EURUSD chart, Pluto EA on another EURUSD chart and PipDefender EA on a third EURUSD chart. We want 
 that PipDefender manage only the orders opened from Goofy EA and that it ignores those opened by Pluto EA. To obtain this we have to 
 know the magic number of Pluto EA and insert it into the EXCLUDE_MAGIC list of PipDefender. 
 Example: 
 We want that PipDefender just manage the manually opened orders and that it ignores all the others. In this case we just need to include 
 0 in the INCLUDE_MAGIC list of PipDefender and so all the orders not manually opened will be ignored. 
 Example: 
 We want that PipDefender manages with different modes the orders opened from two others EA's (EA1 and EA2 that have different 
 magic numbers) on the same cross. To obtain this first we have to use two copies of PipDefender (PD1 and PD2) then we put in the 
 INCLUDE_LIST of PD1 only the magic number of EA1 and we do the same with PD2 and EA2. This way each PipDefender will manage 
 with its own parameters those and only those orders of the EA to wich is associated. It's important to note that by putting in the 
 EXCLUDE_MAGIC list of PD1 the magic number of EA2 (and vice versa in PD2 we exclude the magic number of EA1) we obtain the same 
 result, but, for example if we later open a manual order (or if it's opened by another EA different from the first two) on the same cross 
 then the two PipDefender will run counter each other trying to modify the order! In situations such this it's always better to use the 
 INCLUDE_MAGIC instead of EXCLUDE_MAGIC. 
 Example: 
 We' ve opened a manual order for a position trading strategy, but, on the same cross, we want to use PipDefender also to manage our 
 manual scalping strategy. In order to obtain this we don't have to do nothing more than insert in the EXCLUDE_TICKET list the ticket 
 number of the manual order that has to be ignored. 
 Important note: all the manually opened orders have magic number equal to 0. 

         SHOW_PANEL [true|false] : enable or disable the informative panel printed on the chart  
         COMPACT_INFO [true|false] : if set on true it removes from the informative panel those functionalities actually disabled.  
         EXTRA_LUCK[true|false] : if set on true PipDefender will add a bit of luck to all the trades it manages ;-)  
         PRINT_LOG [true|false] : enable or disable the add of further informations in the Metatrader log space reserved to Expert 
           Advisors  
         PANEL_COLOR: allows to set the colour of PipDefender's informative panel  
         FONT_SIZE[integer number from 8 to 20] : allows to set the size of the fonts used in the PipDefender's informative panel 

  