NavigationUser loginWho's new
Who's onlineThere are currently 0 users and 48 guests online.
|
Trailing stopsHi folks, When we talk about the trailling stop techniques, we are talking about the exit positions strategy indeed. Any trade position you enter has to end with one of two results: you gain profit or you make loss. One of your early days memories describes the confusion of exiting the position in the appropriate time. Tow days after the previous lesson you have opend your pocket and made a bid. The profits bursts out on your face, suddenly the marked turned his direction, you smiled and said "you can't cheat me anymore , I learnt the lesson" the market is still rununing against you and you still smiling. The trailing stop is for these situations where early exit migh prevent the profits to run and late exit migh prevent cutting the loss early. We are going to study how to set the trailing stop by hand in MetaTrader terminal and how write the code that imbed the trailing stop. Firstly let's give the trailing stop the dictionary definition. Trailing stop definition:It’s a kind of stop loss order that is set at a percentage level below (for a long position) or above (for a short position) the market price. The price is adjusted as the price fluctuates (The price is adjusted by an Expert advisor running). Note: The trailing stop modify the order in your client terminal and send the new stop loss level to the broker, So, you have a running terminal to trail your orders and when you shut down the terminal not more trailing stops will work. How to set trailing stop manually in MetaTrader?To place a trailing stop you must have an opened position. You simply go to the position you want to set its trailing stop in the Terminal Window and right click it, that will bring the context menu showed in figure 1, choose from it Trailing Stop sub-menu and you'll get the levels of trailing stop you can choose one of them.
If you didn't find the trailing stop level you want in this menu you can click the last command in the menu "Custom" to bring an input window to set the trailing stop (Figure 2).
MQL4 Trailing stop sample code:
// YOUR CODE HERE!
In the code above we are trailing all the opened position using our function TrailOrder(). TrailOrder() function:This is our function that handle the trailing stop for us. There are two cases of the orders: Buy order: In the case of Buy order we check that the profit ( current Bid price minus the open price) is greater than the TrailingStop value we have set (or the user set) and we modify the order to new StopLoss level which equal to the current Bid price minus the TrailingStop value. Sell order: In the case of Sell order we check that the profit ( the open price minus current Ask price) is greater than the TrailingStop value we have set (or the user set) and we modify the order to new StopLoss level which equal to the current Ask price plus the TrailingStop value. Please refer to my MQL4 lessons form more details! Any question is welcomed!
|