Hello folks…… I wonder if you can help me out?
I noticed yesterday that my trailing stops didn’t move (despite significant market progress in my favour early in the trade), which I assume is because I had two open positions in the same chart. Although the positions were entered by two separate bots (I have one bot for Tuesday AM on the DOW and one bot for Tuesday PM on the DOW), the only thing I can think is that it’s something to do with the cumulative size of my position on that particular chart. I’ve inserted the code for one of the bots below (the other is exactly the same entry rules and code, apart from the hours).
Am I right that it’s something to do with the multiple positions, or is there another reason?
//-------------------------------------------------------------------------
// Definition of code parameters
DEFPARAM CumulateOrders = False
StartTime = 123000
//timeEnterBefore = time >= noEntryBeforeTime
LimitEntryTime = 160000
//timeEnterAfter = time < noEntryAfterTime
daysForbiddenEntry= OpenDayOfWeek=1 OR OpenDayOfWeek=3 OR OpenDayOfWeek=4 OR OpenDayOfWeek=5 OR OpenDayOfWeek=6 OR OpenDayOfWeek=0
indicator1 = SAR[0.02,0.02,0.2]
c1 = (open > indicator1)
indicator2 = Average[20](close)+std[20](close)
c2 = (open > indicator2)
indicator4 = BollingerDown[20](close)
c3 = (indicator1 > indicator4)
indicator5 = ExponentialAverage[13](close)
indicator6 = ExponentialAverage[13](close)
c5 = (indicator5 >= indicator6[1])
indicator7 = ExponentialAverage[8](close)
indicator8 = ExponentialAverage[8](close)
c7 = (indicator7 >= indicator8[1])
IF c2 and c1 and c3 and c5 and c7 and time >=StartTime and time <=LimitEntrytime and not daysForbiddenEntry and not onmarket THEN
BUY 1 PERPOINT AT MARKET
ENDIF
c11 = (open < indicator1)
indicator12 = Average[20](close)-std[20](close)
c12 = (open < indicator12)
indicator14 = BollingerUp[20](close)
c13 = (indicator1 < indicator14)
c15 = (indicator5 <= indicator6[1])
c17 = (indicator7 <= indicator8[1])
IF c12 and c11 and c13 and c15 and c17 and time >=StartTime and time <=LimitEntrytime and not daysForbiddenEntry and not onmarket THEN
SELLSHORT 1 PERPOINT AT MARKET
ENDIF
SET STOP pTRAILING 144
As I see it … you have no exit conditions so the only exit is via the Trailing Stop or swap over of entry condition?
You are using CumulateOrders = False and so you will not get multiple positions anyway?
Attached shows single position only and exits.
Have I got it wrong what you are saying is your problem?
Although the positions were entered by two separate bots
Ah I reread slower … I see now you are saying above … so two separate bots are giving you 1 x position on each / multiple positions.
One bot should not affect the TS on another bot.
Thanks for the reply.
The way it is coded, within one bot there can only ever be one open position but the issue “seems” to be when the afternoon bot opens a position while the morning bot is also still in a position. So even with CumulateOrders = False I do occupy multiple positions on the same chart because they are derived from two separate bots in ProOrder. This could of course be a red herring but it’s the only constant theme I have noticed when my trailing stops have failed to fire in real time. And yes, you are correct that I have no exit rules aside from the trailing stop.
Hope this helps?
The trailing stop in each strategy should be based on the average price of all open positions of that particular strategy. Having multiple strategies on the same instrument should not change anything as each strategy only looks at its own profit/loss values.
Maybe a screen shot of the trade/s on a price chart might help us see what is happening?
It would most certainly make sense that one bot wouldn’t conflict with the other, but I thought perhaps because the default Trailing Stop function in ProReal Code relies on the POSITIONSIZE variable in order to calculate (which by my understanding is cumulative), this may be a plausible explanation.
So putting that hunch aside, why would a Trailing Stop move as it should in most cases, but then become completely static in others?
If you change / add to your code as below and follow the GRAPH values against exits you can see that only way that there is an exit is via the TS??
I have done this quick without much though so just say if you see it different as I might learn something also!! 🙂
BUY 1 PERPOINT AT MARKET
EnterLong = Open
ENDIF
SELLSHORT 1 PERPOINT AT MARKET
EnterShort = Open
ENDIF
GRAPH EnterLong - 144
GRAPH EnterShort - 144
why would a Trailing Stop move as it should in most cases, but then become completely static in others?
You sure that when you think the TS is not moving it is that Price did not increase (decrease for shorts) at all after entry and so the TS would not move and would exit the position when position price moves down (moves up for shorts) to reach the TS?
Correction below.
I think I need to slow down and think!!!?? 🙂
GRAPH EnterShort + 144
Here is a screenshot of one of the offending trades. *Edit* I’ll find a better one and describe it properly. I don’t want to be confusing people. Bear with me…
This screenshot explains it better.
A short trade that entered at 09:52 yesterday. Quite clearly it has performed well in the early bars, and at the time of writing it’s at +259, and yet the stop has never moved from -151 of entry price. I can’t understand why.
Exit of each trade is the stop.
Because you use CumulateOrders = False and you do not use If Notonmarket (on your entries) then when you are Long and price meets short entry conditions then there will be a swap of trading direction (Long to Short) so there will exits by other than the TS.
What I should have said (in my post above) in bold below
If you change / add to your code as below and follow the GRAPH values against exits you can see that only way that there is an exit on some / most is via the TS??
and you do not use If Notonmarket (on your entries)
Yes he does! Check the code in the first post – it is the last condition in lines 31 and 45. More coffee for you I think!
But I do use “notonmarket”. It’s in the code. This isn’t about trades flipping midway through because of another entry signal, this is about trades being allowed to run on to the original stop point, which they shouldn’t do if their average performance has been favourable at any point in the trade. When trade position improves by X, so too should trailing stop position. And I’ve seen the trailing stop function do this perfectly well on other occasions (including some singular trades today), but in my example the stop didn’t ‘trail’ at all.