Trailing stops remaining static when there are multiple positions
Forums › ProRealTime English forum › ProOrder support › Trailing stops remaining static when there are multiple positions
- This topic has 47 replies, 4 voices, and was last updated 4 years ago by Mike Boorman.
-
-
05/08/2019 at 1:24 PM #97945
and at the time of writing it’s at +259
What contract is that?
I ask because Price is at 26050 so about 80 below buy Price (26131) on the Chart you show?
05/08/2019 at 1:28 PM #97947I do use “notonmarket”. It’s in the code.
I can’t see it sorry, what Line number in the code (you show in this Thread) is notonmarket?
05/08/2019 at 1:31 PM #97949It would seem odd that it has not moved the trailing stop in that image. It does not show that you have two positions open on the same market in the image. If you do then it would be interesting to see where the average position price is compared to where the trailing stop is. If it is 144 pips from the average position price of two positions then you might be correct and the broker is applying a trailing stop to your average position.
In the past forum members have not had much joy with the built in TRAILING function and have generally hard coded in their own trailing stops. Just check at the close of each bar if price has closed or reached a new high/low that means the stop should be moved and adjust the stop value accordingly. Using MTF it should be possible to do this every second so that it is a truly fast adjusting trailing stop although this does massively reduce your available amount of back test data.
1 user thanked author for this post.
05/08/2019 at 1:33 PM #97950I can’t see it sorry, what Line number in the code (you show in this Thread) is notonmarket?
05/08/2019 at 1:43 PM #97953More coffee for you I think!
haha yes I agree … I didn’t use the scroll bar to see all the conditions as I usually put not onmarket at the beginning after IF anyway so I assumed it was not there … well it made an ASS out of me but not you two!!!! 🙂
05/08/2019 at 1:55 PM #97957It would seem odd that it has not moved the trailing stop in that image. It does not show that you have two positions open on the same market in the image. If you do then it would be interesting to see where the average position price is compared to where the trailing stop is. If it is 144 pips from the average position price of two positions then you might be correct and the broker is applying a trailing stop to your average position.
In the past forum members have not had much joy with the built in TRAILING function and have generally hard coded in their own trailing stops. Just check at the close of each bar if price has closed or reached a new high/low that means the stop should be moved and adjust the stop value accordingly. Using MTF it should be possible to do this every second so that it is a truly fast adjusting trailing stop although this does massively reduce your available amount of back test data.
Yes, it wouldn’t show the two positions because one of them closed this morning before I took the screengrab this afternoon. Next time there are two positions open and a non-moving stop I’ll calculate the average position price to see if that is indeed the issue.
I’ve read various posts about hard-coded trailing stops as an alternative to the default option, but having spent hours and hours trying and failing to copy them into my own system, I went for the default. I think the reason I failed is because the various stop codes that I’ve found always seems to include extra conditions that I don’t want. All I require is this:
When position improves by 5 points, trailing stop moves by 5 points, else trailing stop stays the same. I don’t need the stop to move instantaneously – I’m quite happy for this to be calculated on bar open or bar close. I think this would only be a few lines of code but I’ve failed to get it right so far. Could you possibly help here?
Thanks in advance.
05/08/2019 at 2:40 PM #97965You could code something like this in to your code:
12345678910111213141516171819202122232425sl = 144slmove = 5if not onmarket and (your long entry conditions) thenbuy 1 contract at marketslprice = close - slsell at slprice stopendifif not onmarket and your short entry conditions) thensellshort 1 contract at marketslprice = close + slexitshort at slprice stopendifif longonmarket and high - sl > slprice + slmove thenslprice = high - slendifif shortonmarket and low + sl < slprice - slmove thenslprice = low + slendifsell at slprice stopexitshort at slprice stopIt checks the high at the candle close and if price moved ‘slmove’ pips above your last calculated stop loss price it adjusts your stop loss to be ‘sl’ pips below that high. The opposite for short trades compared to low.
The only downside is that the starting stop loss is calculated off of the close price because we do not know what our TRADEPRICE is at this point so if there is a gap to the next open then your stoploss might not be the desired distance away. I’ll try to code something to at least correct the stop loss distance after one candle.
2 users thanked author for this post.
05/08/2019 at 2:52 PM #97966This should do it. At the end of the bar that it opens a trade on it adjusts the stop loss based on the actual position price before then checking to see if it needs to move it again.
12345678910111213141516171819202122232425262728293031323334353637sl = 144slmove = 5if longonmarket and sladj thenslprice = positionprice - slsladj = 0endifif shortonmarket and sladj thenslprice = positionprice + slsladj = 0endifif not onmarket and (your long entry conditions) thenbuy 1 contract at marketslprice = close - slsell at slprice stopsladj = 1endifif not onmarket and your short entry conditions) thensellshort 1 contract at marketslprice = close + slexitshort at slprice stopsladj = 1endifif longonmarket and high - sl > slprice + slmove thenslprice = high - slendifif shortonmarket and low + sl < slprice - slmove thenslprice = low + slendifsell at slprice stopexitshort at slprice stop2 users thanked author for this post.
05/08/2019 at 2:57 PM #97968I ask because Price is at 26050 so about 80 below buy Price (26131) on the Chart you show?
Am I correct here or missing the point … about 80 points below on a short and showing + £259 so the contract must be a £3 per 1 Lot contract?
So for a 144 point trailing stop loss then the gain would need to be + £432 before the stop loss would move??
05/08/2019 at 3:02 PM #9796905/08/2019 at 3:32 PM #97972Thanks very much Vonasi – I’m very grateful! I’ll try them and let you know how I get on. I’ll try your initial suggestion first just to be safe, just in case my broker thinks POSITIONPRICE is “all positions in current market” rather than what I want it to be. I guess it’s possible that PrOrder’s default trailing stop function is using POSITIONPRICE to calculate its own position.
05/08/2019 at 3:51 PM #97977I ask because Price is at 26050 so about 80 below buy Price (26131) on the Chart you show?
Am I correct here or missing the point … about 80 points below on a short and showing + £259 so the contract must be a £3 per 1 Lot contract?
So for a 144 point trailing stop loss then the gain would need to be + £432 before the stop loss would move??
No, that isn’t correct. That image was simply illustrating the moment in time when I entered (which was about a day ago…. the trade is still going on as we speak and at the time I originally posted it was 276 point in profit). It is also illustrating the fact that the price (listed on the left) at the time of me taking the screengrab was massively in profit but the trailing stop, again, remained unmoved from the default position at entry. Disregard what the price was on the furthermost right of that screenshot – it simply doesn’t matter what the price was at 12:24 yesterday.
Two things should have happened to that trade:
1. As the that short trade quite clearly did well initially, the trailing stop should have moved from its initial point of 151. Although the screenshot cannot retrospectively tell us where the stop was in that period of time yesterday, you have my word that it didn’t move.
2. With the trade at 276.4 points in profit (at a pound per point) the following day (as the screenshot shows), there was still no change to the initial stop. So you’ve got a good start to a trade and you’ve got an even better current position, and yet neither run of form availed a change in the stop.
And so eventually, even if that trade goes up a thousand points this week it’s fair to assume it will only sell whenever the market hits a 151 loss on the entry point. This is the issue. In other trades I have observed with my system, that stop would have responded to the favourable market and moved significantly towards the entry price (and would probably have surpassed it by now, thus locking in a guaranteed profit).
05/08/2019 at 4:29 PM #97983No, that isn’t correct.
Thanks,
It seems well weird and we do need to get to the bottom of it. There was somebody on another thread a few days ago with issues with the default Trailing Stop and I myself have never had much success with it.
Do we know if there is a maximum value for TS beyond which TS becomes ineffective?
We would expect a warning from the Platform when we set TS beyond extremes, but as we know … the Platform is far from perfect, but it will all be different with version 11 !? 🙂
05/09/2019 at 8:11 AM #98015You could code something like this in to your code:
12345678910111213141516171819202122232425sl = 144slmove = 5if not onmarket and (your long entry conditions) thenbuy 1 contract at marketslprice = close – slsell at slprice stopendifif not onmarket and your short entry conditions) thensellshort 1 contract at marketslprice = close + slexitshort at slprice stopendifif longonmarket and high – sl > slprice + slmove thenslprice = high – slendifif shortonmarket and low + sl < slprice – slmove thenslprice = low + slendifsell at slprice stopexitshort at slprice stopIt checks the high at the candle close and if price moved ‘slmove’ pips above your last calculated stop loss price it adjusts your stop loss to be ‘sl’ pips below that high. The opposite for short trades compared to low.
The only downside is that the starting stop loss is calculated off of the close price because we do not know what our TRADEPRICE is at this point so if there is a gap to the next open then your stoploss might not be the desired distance away. I’ll try to code something to at least correct the stop loss distance after one candle.
This works brilliantly! The backtest results over a year are very close to what they were with the TRAILING function, and when I watch the trades in real time the stops move exactly as they should.
Thank you so much Vonasi!
05/09/2019 at 8:15 AM #98016Do we know if there is a maximum value for TS beyond which TS becomes ineffective?
It doesn’t look like there is. I saw a 150+ stop work perfectly fine on the same market earlier in the week, and then suddenly a load of others (most of them smaller) decided not to! But no matter – it seems Vonasi has provided the solution.
-
AuthorPosts
Find exclusive trading pro-tools on