I don't like your attempt as it does not clearly distinguishes between buy and sell but you speak about highest...
Firstly You have to understand what is a stop order, what it does and when it probably surprises you as it is not a guaranteed price!
Read e.g. this: https://www.schwab.com/learn/story/3-order-types-market-limit-and-stop-orders
Then a trailing stop is in most cases 'trailed' so it keeps e.g. a certain distance if the price moves in the 'favourable direction' or it is move by the use of an indicator like the Parabolic SAR (part of the MT5).
Here is in short what a trailing stop is (from: https://www.investopedia.com/articles/trading/03/080603.asp)
Trailing stops are orders to buy or sell securities if they move in directions that an investor considers unfavorable.
The trailing stop technique is the most basic for an appropriate exit point, which maintains a stop-loss order at a precise percentage above or below the market price or above.
The momentum-based technique throws fundamental analysis into the picture by introducing the concept of being overvalued into your trailing stops.
The parabolic stop and reverse technique provides stop-loss levels for both sides of the market, moving incrementally each day with changes in price.
The SAR is a technical indicator plotted on a price chart that will occasionally intersect with the price due to a reversal or loss of momentum in the security in question.
- www.schwab.com
To code it use variable that records highest price on tick, and close trade when current price will fall TS value below this variable.
Hello,
I am finding little difficult in understanding Trailing Stop loss. How does it work, does it take value from Stop Limit, Trade Entry Price or Current Price or Highest Peak in Favorable direction.
After reading some blogs about Trailing Stop, This what i understand :-
To graphically understand a trailing stop, in the case of a long trade, you can draw a rectangle from Your entry price down to Your initial stop loss and extended on the right side of the chart.
If You trail the top of the rectangle to any new higher price made from the market You'll find the base of the rectangle corresponding to Your actual stop.
Your understanding of trailing stop loss is on the right track, but let's clarify it further to ensure you've got a complete grasp of how it works.
A trailing stop loss is a dynamic stop loss order that moves or 'trails' the market price by a specified distance (the trailing stop value) as the price moves in a favorable direction.
It's designed to protect gains by enabling a trade to remain open and continue to profit as long as the price is moving favorably, but automatically closes the trade if the price changes direction by a specified amount.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am finding little difficult in understanding Trailing Stop loss. How does it work, does it take value from Stop Limit, Trade Entry Price or Current Price or Highest Peak in Favorable direction.
After reading some blogs about Trailing Stop, This what i understand :-