Help please Stop distance orders being rejected?

Forums ProRealTime English forum ProOrder support Help please Stop distance orders being rejected?

Viewing 13 posts - 1 through 13 (of 13 total)
  • #230678

    Hi guys I am using this trailing stop code and it is working but when the trade is closed it is stopping running the system with this error message : The stop was closer than the minimum required distance from the market

    Have been using this code before and this was not happening so not sure why it is now, the code works but when the limit creeps up and position is closed in profit the system stops running and I have to turn back on, any ideas would be much appreciated.

     

    trailingstart = 25 //trailing will start @trailinstart points profit
    trailingstep = 1 //trailing step to move the “stoploss”

    //reset the stoploss value
    IF NOT ONMARKET THEN
    newSL=0
    ENDIF

    //manage long positions
    IF LONGONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND close-tradeprice(1)>=trailingstart*pipsize THEN
    newSL = tradeprice(1)+trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND close-newSL>=trailingstep*pipsize THEN
    newSL = newSL+trailingstep*pipsize
    ENDIF
    ENDIF

    //manage short positions
    IF SHORTONMARKET THEN
    //first move (breakeven)
    IF newSL=0 AND tradeprice(1)-close>=trailingstart*pipsize THEN
    newSL = tradeprice(1)-trailingstep*pipsize
    ENDIF
    //next moves
    IF newSL>0 AND newSL-close>=trailingstep*pipsize THEN
    newSL = newSL-trailingstep*pipsize
    ENDIF
    ENDIF

    //stop order to exit the positions
    IF newSL>0 THEN
    SELL AT newSL STOP
    EXITSHORT AT newSL STOP
    ENDIF

    set target pprofit 100

    #230679

    Have been using this code before and this was not happening so not sure why it is now,

    Loads of Instruments are at or near ‘All Time Highs’ and so this results in loads of volatility which means that brokers push out / widen the minimum distance to price at which trades can be executed.  If we are within the minimum distance then the trade is not executed and the System is Stopped.

    Try ticking the box ‘Auto-Adjust Stops‘ when you start your System … it may help?

    #230686
    JS

    … And it could be due to the (short?) time frame in which you use the trailing stop now… with a short time frame, in combination with the small “trailing step”, you will soon be in the “forbidden zone” that GraHal describes…

    #230692

    Ok thanks guys very frustrating was working great – have also seen there is another thread on this topic

    #230693

    Have been using this code before and this was not happening so not sure why it is now,

    Since when exactly does this happen ? (date)
    Did you change anything ? (anything)

    The solution GraHal describes should help. But a reason that this suddenly would be necessary without changes on your side, I don’t see (including GraHal’s reason 😉 )

    #231471

    How many times are you guys finding your orders being rejected?

    From a quick read around it can be ‘news-event-bound’ and / or time of day where liquidity begins to zero. Keen to see whether the days morning sessions through late morning is kind of sane for you all in terms of rejections on EU markets moreso.

    Also keen to hear whether US events can knock on later in the session EU session as well (afternoons?).

     


     

    I’ve never traded with systems or indicators of any significance before and am on an EDU journey with a younger family member looking to perhaps bundle a little bit of IP from generations past and systems present. It’s more for them but I will not lie, the idea of pre-canning as much as I do for housekeeping purposes has led me down a bit of a discovery path, so starting from a low IP base there’s many questions (this forum has been so useful).

    Loads of Instruments are at or near ‘All Time Highs’ and so this results in loads of volatility which means that brokers push out / widen the minimum distance to price at which trades can be executed.  If we are within the minimum distance then the trade is not executed and the System is Stopped. Try ticking the box ‘Auto-Adjust Stops‘ when you start your System … it may help?

    Does this burn pending stop orders being placed as well? Sounds like it might. So you end up with open positions (potentially other resting orders as well) and no system as it’s been Stopped? Strewth!

    So is? the logic here if you’re pending (resting either entry/stp/lmt or exit/stp/lmt) prior to any event (entries earlier before)(how early is early enough, ha) you should be okay BUT if moving orders around (system or otherwise too maybe) you could be caught out by broker imposed min. limits – so req. the use of market orders, which come with there own issues (slip etc).

    That said, there’s also perhaps the issue of how your ‘execution’ is manhandled in the event your ‘tp/stp’ is reached during news events etc. which is what you said above Gra.

    Is the logic here (if any by me) given some systems are aligned to shorter term gains and trigger on lower TF that here is where you get caught as your trade-logic has you so close, and infact w/in the spread (due to it *widening* or *whatever-intervention*) which is impossible with a market maker and so you take a bath?

     


     

    Been stalking these and other other threads and while at times it seems a mixed bag, it gets you thinking and coming to similar conclusions as other’s have arrived at – avoid news – TimeForbidden (as in Time of Day and Day).

    Generally speaking many of our positions ARE affected by news in a good way, so we’d be triggering an exit the other side of it or through it and as it stands anything less than MKT with prt-ig could be rejected – even manual trades via there own platform perhaps could fall foul of this kind of thing. No givens etc.

    All is not bad but it’s related to market makers and even DMA can widen spreads as we saw through GFC as Bear and Co. went through the hoop.

    We don’t news trade but how can anyone NOT be affected.

    So I’d prefer a wider spread, than no spread haha

     


    We DL a calendar as housekeeping (and pipe into a custom alarm, music of your choice!), probably should API the thing, similar to what another chaps referenced in another thread re: Public Holidays.

    Maybe we pipe specific TOD for relevance (into Time/DaysForbidden) on day X, I know Roberto had a hamburger with the lot coded somewhere. Could be massaged for Jackson Hole etc etc if need be.

    I kind of already do this and perhaps it needs looking at (to be reflected w/in the system we’re building as a trial) but although doable I’m not sure whether there’s not a more efficient process for a simple (nothings simple) for a ‘starter-algo-system’.

     

    Just want to say many thanks to all that post and have posted, sharing there journey so newbies can get a handle on how they might want to approach things by examining past issues and fixes. I see this forum as ONE BIG break-fix changelog, so many thanks to ALL of those that make it happen …. 🙂

     

    And Gra’s Snippet link (that so many of my searches come back to):

    https://docs.google.com/spreadsheets/d/1rgboqj7sVwsP9ZRhOduOefye48QMWC07jWVXCl-KJPU/edit#gid=0

    Is this pinned anywhere, if not it should be imo.

     

     

    #231472

    I’ve never traded with systems or indicators of any significance before and am on an EDU journey with a younger family member looking to perhaps bundle a little bit of IP from generations past and systems present.

    All you (and your younger family member) need to know is that it happens and that you can’t do anything about it, except for being prepared to restart your system(s).
    Yes, only use Market orders helps. This world, regardless the broker, is not prepared for your pending orders and PRT is not prepared to counteract them.

    There has really been said enough about this, or, there really has been done enough about it. There is nothing left.
    Only one yesterday (see below, Amsterdam time) because it is about the only one left with pending Limit and they will be thrown out when IG permits. So don’t tempt them, use Market orders, don’t even think that it will cost you a bit extra, but earn a bit more for compensation. That is what I do, and it brings peace of mind.
    There’s no more lyrics.

    #231479

    Many thanks Peter.

    Apologies if re-hashing just want to put it to bed …. 🙂

     

    I want to ask a bit about IB and how you’re finding them, bit off topic but from memory @Justisan has been kinda happy with them, is there a bit more resilience there do you think?

    (bit of an issue for the younger family member with IB, they don’t yet meet the min 40k PA to open an acc. that’s needed, not sure if it’s worth them swinging for the fences anyway)

     

    #231480

    Ah crap, just catching up on earlier posts in the IB thread, hope all is sorted now for you all … !

    https://www.prorealcode.com/topic/automated-trading-interactive-broker-prorealtime/page/6/

     

    #231481

    IB, in quantity, bears the same issues; AutoTrading is as decent as you can make it yourself. The difference with IB is that you are always able to reason what goes wrong and next just don’t do that any more; it can all be explained, though there is no prewritten book for it. IG is different, because they shift goal posts and you can never tell in which direction; you won’t be able to tell your cousin (?) that this was the day you could have gained a nice sum of money, but IG shut down the game because they are too busy dealing with Peter’s orders. But you can learn (her) to live with it.
    But could you really ?

    The other day I was refreshing my son’s knowledge on this all. He had been out of this game for 4 years or so. It started to occur to me that each sentence from me, ended with but’s and don’t and maybe’s – and I started to feel ashamed. Ashamed that I actually could not present a decent “course” any more, because these days all has to be looked through special PRT glasses. This is in the realm of “don’t you like the backtesting result unexpectedly ? can you try it again ? I mean, you are working with V12, so you are in the lap of the Gods now and I don’t know“.
    How can I explain to him that he better uses Market orders everywhere because … … these stories have become too long and too weird and too full of undecency. In addition they now need to come with sub-courses on how a market order is not bad at all, because … (and explain the whole shebang of what happens on the exchange and with market makers vs the others etc.).

    Maybe you noticed that the youth of these days will not have the rest/time to work this all out into a consistent whole which can be understood. It takes years to get it all together. Avoid the knowledge will mean that soon the monitor or laptop is thrown out of the window. And so it is best that right from the start it’s told this is part of the game.

    Inv, maybe I see your prospectus (and forgive me if I see that wrongly), but you could be someone with the knowledge, your cousin having the programming skills to translate your knowledge into nice $. You know it can be done inherently and so you both sit down together. But this relatively evil world is against you both and you both can only learn how to conquer it by experience. But once you can (I feel I could be closely there myself), you will know that you do better than all those who did not master that part (yet). So there lay your chances. Remember, the edge. But this is an edge just the same. It can hardly be taught if you don’t know it yourself. But she can find out herself. If she only expects it.

    I think for her it is best to learn to survive within IG because of the lower requirements, and especially because of the possibly much lower investment (like 0.5 $1 point value contracts of 18000 per piece for cash Nasdaq), like ~USD 9000. IB’s equivalent would be ~USD 36000. No need to wait for the wages-increase. One needs real-live playground. And IMO 36000 is beyond that.

    1 user thanked author for this post.
    #231483

    I modified the code so that it requires a DISTANCE:

    you may want to comment out the AT MARKET exit lines in case you prefer to wait for the next candle when there’s not enough distance from the current price.

     

     

     

    #231531

    dears,

    summarizing min.distances issues at IG I would say one has main 3 ways to “solve” it:

    1. avoid those periods
    2. use market orders
    3. move to futures trading

    1: hell, I hate this option… I don’t trade news, but as @inverse mentioned: trading of all of us is affected by news. and for my part I can say it’s affected positively. and implementation of “avoiding” is close to impossible if one trades automatically (for that one would need to know a) in advance b) when and c) for how long IG will implement those min.distances), and it would be damned effort if one trades manually, especially if one trades multiple instruments.

    2. well, that works… but just for certain type of strategies I would say. I was backtesting my core strategies, which trigger entry signals on 5-10-15min time frame and entries are executed with stop orders, changed them to multitimeframe, so signals were still on 5-10-15min but entries “at market” on 1min time frame. systems were still profitable, but man, over 10 years of backtesting systems were performing 20-30% worse. that is for my taste too much. okay, I could have gone down to 1 sec time frame, decrease of performance would be definetely smaller, but honestly, I personally don’t want to “challange” PRT’s/IG’s(and not even IB’s) servers with that tiny times frames… so indeed – again for me personally – changing my stop entries/exits to market orders is for majority (not for all) of my systems a no-go-solution. especially if you have the option:

    3. here you simply don’t have that BS with min.distances… full stop. of course one has to be able and ready to accept all the disadvantages of futures trading in general and with PRT/IB in particular.

    happy trading!

    justisan

    3 users thanked author for this post.
    #231673

    thanks i will try this also

Viewing 13 posts - 1 through 13 (of 13 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login