DAS Trader Advanced hotkeys part 11
Conditional exits for existing positions
Exit a position with bar by bar method - trailing stop to previous candle bodies.
For the purpose of this article I expect you already understand how naming of windows, hotkeys or indicators work which has been covered in the previous article series. This is also an improvement of the extended hours exits from the previous article number 8, so please see the difference in the calling of the position exit. In the article 8 I call a function on the montage window just as I would click if I was trading with the montage and this post calls the usual hotkey I use for exiting trades using my hotkey keyboard.
The goal is to have a trailing stop which would exit my position once the price action breaks the previous candle high (shorts) or low (longs).
Notes
This works even in extended hours as it is calling a natural hotkey you use for exits, so it depends on your hotkey. If you use limit orders for exists, you can use it in extended hours. For market hours, a market order is just fine.
The script is basic and does not check if the order sent has been filled or not, so it is better to give some room for the exit in the hotkey.
My exit hotkey for short trades is as follows
CXL ALLSYMB;Route=SMRTL;Share=Pos;Price=Ask+0.05;TIF=DAY+;BUY=Send
The hotkey is named “Sell100” in my hotkeys config window.
For the bar by bar exit script, I am using this logic
Where PCL means Previous Candle Low and PCH means Previous Candle High.
For visibility, I am drawing the blue horizontal line to the spot where the trailing stop currently resides, as it is virtually invisible.
You can obviously do this on any time frame candles, for the educational purpose I chose 1-min chart.
Example
If I short NVDA 0.00%↑ and enable the trailing stop
The blue line indicating my actual stop is drawn and the next minute it will be redrawn automatically
then again
until it eventually triggers
The script that does this functionality is quite simple (after we prepared some variables first)
Keep reading with a 7-day free trial
Subscribe to Peter’s Substack to keep reading this post and get 7 days of free access to the full post archives.