PRT to IG trade delays

Viewing 14 posts - 1 through 14 (of 14 total)
  • #217895

    Hi All,

    Had some trading complications today and hope anyone else maybe had seen this before and could comment.

    Traded with PRT algo on IG live account: US Tech 100.

    Watching the algo run in real time there is a lag between PRT opening the trade and IG opening the trade. Had various trades doing the same.

    Attached is a screenshot.   The larger white circle is PRT trade open. The smaller white circle with a blue line is IG trade open. Around 2 minutes 45 seconds, the delay and the point difference in the opening was around 13 points.

    #217899
    1.   Is the equity curve and long position from the Algo running under ProOrder?

    2.     What is the source of the time / white circle position opened?

    #217900

    Watching the algo run in real time

    Does above mean … watching a backtest continue to run forward in real time (often referred to as Demo Live running)?

    #217906

    Hi Grahal,

    It is allowing a PRT test to continue running by selecting real time at the “Time Period”. I would think the time displayed on the PRT screens is the time as per my PC. I also compared this with the IG webpage open on the same chart. Both PRT screen and IG webpage seem to be similar. The next is to look at the time recorded on the actual ticket provided by IG of the trade.   This again line up with the blue line as per the previous attached example. The ticket time I would think is the IG server time.

    I would expect some time difference in milliseconds (processing and internet latency) between PC time and IG server time but not minutes. Latency test done online suggest difference between my time and London as around 268 ms.

    What are your thoughts?

    #217908

    Hi Pieter – trying to help out …

    The Amsterdam time of this post is 02:31 am. What’s your time at that moment ?

    Otherwise the Larger White Circle denotes a (forward) Backtest – not Live. Is that correct ? If Yes, all is a bit moot, I think.

    #217909

    Hi Peter,

    Amsterdam 02:31 am is Brisbane 10:31 am.

    Yes, it is a backtest that are continue to run. I would think this is similar to the actual algo running on the broker’s server. I am not aware of a reason that there should be a difference between the two. IG confirmed that the backtest is running on the PRT server in France. The potential delay between when the server executes it in France and me seeing it in Brisbane should not be more than the internet latency between a destination which is around 250 to 300 milliseconds from previous latency testing. What happened today is minutes and a very visible move in the market due to the delay.

    As mentioned above I compared the PRT times I see on my PC with the IG webpage which I would think is an IG server page view and there is no visible difference in time.

    When I do some manual trading using PRT I can see a slight lag (maybe a second) between when I press the button and when the trade occurs. This I would think is purely latency. The idea of algo trading for me is to reduce this time delay by having PRT execute this on servers closer to the action. Discussing with IG today they have as per normal referred this to PRT for comment.

    #217911

    Hi again Pieter,

    I dare to guarantee you that this is not a(n extreme) latency issue.  So I do 😉 …

    Assumed you can work with a Market order for testing, you may do this :

    Notice that you’d need to put this in a copy of the system you will put to Live, as this won’t run Live because of the Graph command.
    Now start the Live system (or have it running already).
    Next start the above code (within your own code) as a Backtest, and start this with a time before the Live system has taken an order (or will take one).

    A spike in the separate pane from the price pane will show you when the backtest (forward test) took the Entry. It should be the same as the Live system (it will be 🙂 ).

    If you are working with Limit orders, let me know, then I can extend the example somewhat – it is a bit more difficult to show what’s going on with that. But it can be done.
    And *if* you are working with Limit Orders, it most probably is your “problem”, because Backtest may not do the same at all as Live. But that’s for a next post (if you use Limit orders indeed).

     

    1 user thanked author for this post.
    #217922

    Sorry, but how do you compare a backtest and an algo running live in ProOrder?

    “backtest that are continue to run” do not send order to be opened by the broker.

    Also, if the same algo is running on ProOrder, orders might run differently depending on your code for many reasons: calculation made over X bars, wait Y bars between orders, …

    Attached is a non-exhaustive list of the elements that can impact a live trading strategy and create differences with a demo account and/or backtests:
    1. Spread
    2. Slippage
    3. Orders rejections due to one of the above reason, but also because of the allowed distance from current price to put pending orders (known as “minimal distance”)
    4. Different trading hours (ProOrder code launched in a different time zone / custom hours, by the user)
    5. Coding problem: division by zero error, null or negative periods for indicators, ..
    6. Lack of responsiveness of IG demo servers (if IG is the broker), although this has improved considerably since last year.
    7. Make backtests without tick-by-tick option
    8. “set stop trailing” instruction that give IG the total control of your stoploss, can be moved differently between accounts due to points above
    9. Limited risk accounts and their rules
    10. Guaranteed stoploss rules and fees
    11. Starting a strategy at a different time (1 hour or even 1 minute later): depending on the code of the strategy, the results of some calculations could be different.
    12. Margin required on the trading account (no demo or backtest tests are made on this subject)
    13. Overnight and overweekend fees
    14. Automatic adjustement of stop orders checked or not when launching the ProOrder
    15. Minimal distance used in backtests for pending orders, not the same as in real trading, due to broker requirement
    16. Different contract size between backtests and live
    Because backtests are only tested on history *with no connection to live market* , you may encounter differences with real live trading environment subject to spread enlargement, slippage, etc. If your stop hasn’t move, there must be information of an error into your orders rejected list you can consult with CTRL+O.

     

    1 user thanked author for this post.
    #217926

    Sorry, but how do you compare a backtest and an algo running live in ProOrder?

    I am not sure if that was addressed to me, but just in case it was … of course this is possible. Sorry for the huge screenshot in the 1st attachment, but else the orders are pinched together. When this position Exits, they will both (Live and Forward Test) exit at the quite exact same (price) position (like attachment 2 shows). No need to add that in a next post, right ?

     

     

    “backtest that are continue to run” do not send order to be opened by the broker.

    That is not important, if you only can interpret what is happening. Your list is full with truths of course. But none of the items ever bother me, which is or because I covered for it, or because I can see through it.
    For IG you should add “lack of broker presence” to the list. This is worse than “slippage” although people tend to call it that.

    Of course it is not simple at all and it is not for everybody to cover for everything via the program code. It is also not for everybody that your only real possibility to get it all running is : test everything in Live. A year ago (July) I started to do that for IG and in November I was finished with it. Dozens, really dozens of “situations” which all MUST be covered for, or else you lose money on wrong expectations to begin with. In November I was finished with that. From then on I never touch the 21 Systems there running any more, but I still do restart some regularly because PRT kicks them out due to broker anomalies I can’t cover for.
    In January this year I started the same trajectory for IB and this is still far from finished. So Yes, my backtest will run smoothly over the period of 6 months, but a Live system is kicked out each couple of days (or worse). Should that be part of your list ? of course not. Still these situations obviously cause Live and Back -(or Forward-) testing not to be in sync.  It is as obvious as can be.

    Now back to Pieter’s problem, which I suspect to be in the realm of Limit orders. Or something else after all. Btw, the Limit order thing (or Stop order for that matter) is actually not explicitly in your list; Pending orders are always filled with Backtesting once the price is touched. Not so with Live because of the market mechanism, not to speak about partial fills which I never see happening with IG but which happen all over the place with IB. For me, this is the most occurring reason for the Entries or Exits to be in another bar (or the price being slightly off in the same bar). And Yes, this can heavily distort the backtest results (and Forward Testing results) compared to Live. Example in the 3rd attachment (10 seconds difference between the first partial exit and the remainder). And if not fully filled at all, things will plainly go wrong (trade ends in error and system is kicked out).

    #217938

    Thanks Peter. I will try this.

    #217942

    Hi Nicolas,

    Thank you for your response.

    I am well aware that the running backtest does not place any orders. Unfortunately, there is no facility within PRT to have a window to just view the algo while it is running live on the broker’s server or wherever. We have the function to view the equity curve, open and close arrows, and long or short but that is it. If you have an algo running with various indicators or lines and you want to see how this progress and develop in a live environment on the real market this is not possible. So the only alternative is to use a running backtest as it at least shows how the trade develops. For me is just a viewing window.

    What concerned me yesterday is that the forward running backtest runs the algo and you can see that in the simulation certain orders are opened, stops and targets are placed but on the IG side the order is nowhere to be seen. It took some minutes for the orders to open and close and far away from the actual open and close points as per the forward running backtest. This makes me wonder what is really happening with our actual running algos in a live environment. The running backtest is maybe not the best viewing window as you suggest but what else is the alternative?

    My algo used market orders which on the US tech 100 should fill instantly. I code my own stop losses and targets to circumvent IG’s minimum stop loss and target levels.

    #217944

    You can visualize automatic orders on your chart, when checking the performance chart/orders list of each strategy of the ProOrder list (image attached).

    Once again, I’d like to make it clear that there may be differences in the times at which orders are executed between a backtest and a strategy that’s already working, depending on the conditions included in the backtest.
    Indeed, for reasons of calculation depending on your own code, this is quite likely, for example:
    _ I only allow 2 orders per day
    _ I wait 20 candlesticks since the last order
    _ no more than X trades per week
    _ daily stop trading after a loss
    _ etc.
    Again, since I haven’t read the code, I can’t comment on the precise reason for the discrepancies observed 😉

    1 user thanked author for this post.
    #217962

    Hi Nicolas,

    I worked through your list and it is item 11 that caught me out. The PreLoadBars function is used for some of my indicators. The live algo will use 200 bars from when it is started and if I load the forward backtest it will load 200 bars from when I started that. So the different start times cause a discrepancy if used with the function ONCE BL = CLOSE as this load the CLOSE from the first bar of the PreLoadBars function.

    Thank you for the assistance and the list, much appreciated.

    #217963

    Hi Peter,

    Tested the “GRAPH ENTRY” code and it works as you described. Thanks for that.

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

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