Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Getting a stop loss to transmit based off desired entry rather than broker fill
I've been using MC for quite some time and never quite got around to figuring this out - some weeks it effects my results more than others and this week was one such example so I've endeavoured to try and solve it. I much appreciate the assistance.
I find some of the auto trading logic in MC a tad opaque, but I might just be a bit slow, more than possible!
Essentially what I want to do is have stop losses transmit not based on the broker fill, but on where the strategy wanted to enter. So for example if I wanted to short the EURUSD at 1.1500 with a 20 pip stop, regardless of what fill I get from the broker I want my stop loss transmitted at 1.1520 and not say 1.1518 if the entry price at broker was actually ultimately 1.1498 or similar due to spread/slippage etc. However I don't want to use async trading as I've had some utterly bizarre results using async in the past and I think it's best left alone.
I'm aware that this means I have to accept the spread as an extra cost and that the average loss will be magnified. I modelled this and the overall cost of the spread added on stops vs being stopped out early was quite a bit less, especially since my stops tend to be in areas where price is likely to meet resistance (this logic can become flawed if the stop is now just prior to that resistance as a result of an inferior broker fill vs strategy placement if you see what I mean).
Is there any combination of auto trading settings that can achieve this or would I have to code a manual stop using IOG where it takes the strategy price and calculates the stop based on that, ignoring the broker price. My only concern about this is that I seem to recall the strategy price can end up sync'ed with the broker price in sync mode so even that may not work.
I am using the PowerLanguage version of MC.
Thanks very much!
Can you help answer these questions from other members on NexusFi?
Yeah agreed because using sync trading the keyword EntryPrice (which is technically a strategy based keyword) becomes synced with the broker fill report anyway and I'm not aware of any keyword for entry price that disregards broker fill.
As you say I think the best way is to take the entry signal generated stop price and feed that to the stop loss signal to build a stop loss from.
With relatively complex entry logic this can be a bit of a pain to think through and ensure nothing weird is going to happen in live - probably the best thing to do is assign a stop loss variable on entry using "if barssinceentry = 0" to stop the stop loss being moved around as redundant entry signals are generated post entry. So you wouldn't have a stoploss(entryvar), but rather a stoploss(stopvar) where stopvar was assigned to entryvar when barssinceentry was zero. It's a shame because MC does essentially "know" or at least knew its desired entry price, but this seems to disappear as a global variable.
I do have an open ticket with MC themselves about this so will post in the thread if they have an easier option.
Other options are obviously things like adding on the mean spread to your stop loss etc, but this is inelegant.
Eager to hear what the MC team has to say about it, I'm sure they can have a workaround. If not, some complex coding is due and beware of the possible contingencies that often arise in this situations..
If I understand this topic and your goal correctly, you can also use the average entry price from the broker side as a good substitute for the `EntryPrice` keyword. See the AvgEntryPrice_at_Broker keyword, for instance.
based on your goals coding a stop yourself using IOG appears to be the best option. The price "where the strategy
wanted to enter" sounds like something that you can track within your code, then just base the stop on that price.
Maybe add an option to use the actual fill price in case the fill would result in an immediate stop out due to the computed stop being surpassed already.