0 Second Transaction
Forums › ProRealTime English forum › ProOrder support › 0 Second Transaction
- This topic has 31 replies, 5 voices, and was last updated 2 years ago by
PeterSt.
-
-
09/10/2022 at 5:30 PM #200502
Hi @B&L
A while ago I had a problem with a code where the “StrategyProfit” did not work correctly and therefore wrong numbers of contracts were executed.
In my code I went from LONG to SHORT in one go and vice versa:
If…
Buy x contract at Market
…
SellShort x contract at Market
…
It turned out that this change of position was carried out (by IG) in one bar…
Everything worked fine again when I changed the code to…
If…
Buy x contract at Market…
…
Sell at Market
…
SellShort x contract at Market
…
ExitShort at Market
…
The Long position is now closed in one bar and in the next bar a Short position is opened (or vice versa), so everything now runs in two bars.
I don’t know if you go from Long to Short in your code all at once, but it can cause problems because part of your code will no longer be read in the correct order or as you intended.
09/10/2022 at 5:46 PM #200503I post here an example of reversing position that resulted in a misstrade.
The long positions (4.05 contracts ) starts on the correct candle ( GREEN ARROW). The short position is closed on the candle atfer ( RED) (3 contracts)and then another 3 contract are sold short without any reason ( Orange Arrow) ( 3 contracts)
The result leaved an unwanted position of +1.05 contracts on market….
I forgot to mention that defparam is always (Cumulativeorders =False ) and that the first triggers are always blocked by execution on IF NOT ONMARKET
09/10/2022 at 6:05 PM #200506The long positions (4.05 contracts ) starts on the correct candle ( GREEN ARROW). The short position is closed on the candle atfer ( RED) (3 contracts)and then another 3 contract are sold short without any reason ( Orange Arrow) ( 3 contracts)
If you did not accidentally switched first mentioned Short from a Long, then it is indeed heading towards what I suggested : you force the broker to sell the short which will be a Market Order. This only means that you should not do that. What happens next for unwanted situations is not really important, because you think that the Long happened at the Green Arrow, which it did not because it can’t. What would be so is that PRT shows the green triangle at the wrong bar.
Assumed I am still correct, I would not try to solve a wrongly implied situation. Instead you should not let it happen. Instead of having a Limit on a Short, make that a Stop on the Long *first*. Continue with that in the next bar, or make a market order of the inversion in the first place (have 3 Long, Sell 6 Short OnMarket).
09/10/2022 at 6:28 PM #20050709/10/2022 at 6:33 PM #200508I don’t see in either screen image that you are left with a position of 1.05 contracts.
You buy 4.05 contracts and your short position of 3 contracts is closed by a buy order of 3 contracts, so you are then with 4.05 contracts Long…
Here it is… Manually closed
09/10/2022 at 6:36 PM #200510Both orders are stop orders, none of them are limit. You close a position at a price and you also trigger a position at the same price. If you are long and you want to reverse you sell at a stop and you sellshort (also stop) at the same price. There should not be a need to wait a candle
09/10/2022 at 6:48 PM #20051109/10/2022 at 7:03 PM #200512I believe you, that’s not the point, but in the cases shown you stay 4.05 contracts Long in the ProBackTest and also in your overview (4.05 + 3 – 3 = 4.05)
On backtest it shows what it should do ( and on 99% the cases happens daily ) but in reality in this case did not.
The full math in reality is: -3 ( open short position), then closeposition (short) with a +3 (Tot=0) and open+4.05 (tot=+4.05)and finally the unwanted order of another -3 which leaves you with the +1.05
Reversing a position should be always included on the same order. If we are long+1 and we want to go short one contract the execution is to sell 2.
Probably the problem is that when PRT does not follow this order but puts the close position after the open of the reverse position , sees it as a problem and sends immediately an order to close/reopen thet position
09/10/2022 at 8:23 PM #200515What do you use in your code?
- Buy – SellShort
- Buy – Sell / SellShort – ExitShort
About IG:
When IG reverses a position, the current position is always closed first (ID with C on the end) and then a new position is bought or sold, this never goes in the same order (at least here).
09/10/2022 at 8:53 PM #200516What do you use in your code?
- Buy – SellShort
- Buy – Sell / SellShort – ExitShort
About IG:
When IG reverses a position, the current position is always closed first (ID with C on the end) and then a new position is bought or sold, this never goes in the same order (at least here).
I do use the first version: Buy and reverse with sellshort. It’s strange as IG on my side always does the opposite: open first and closes second. An example here
09/10/2022 at 9:48 PM #200518When you use the first version, you may have problems reading your code. As you know, your code is executed at the end (close) of each bar, when you use version 1 and there are changes in your position during the running bar then your code does not “know” that things have changed. When the code is executed again at the end of the bar, certain things can be misinterpreted.
In my case, it was the “StrategyProfit” that is only updated when a position is closed. Because I went from Long to Short in one go (and vice versa), the “StrategyProfit” did not interpret this as closing a position and the “StrategyProfit” was not updated, with all the consequences that entails.
So, what I’m trying to say is that unwanted effects can occur when you use the first version…
09/13/2022 at 4:05 PM #20071310/18/2022 at 8:23 AM #202754Time has passed and IG is blaming PRT, PRT is blaming IG but clients still loose money on a issue that should not occur…
Apparently there is no solution to avoid that either PRT or IG decide on their own to instantly close the trade and charge their clients for the spread. I’m starting to think that only lawyers could solve this…
10/27/2022 at 9:05 AM #203114This could be off-topic in here, but I may expect some knowledge from others who responded to the topic :
See the losing trade from 7:03.02. My Strategy does not do such a thing (incur for that small loss).
The _C orders I have more often – nothing strange with them. However, the text “Close position” (Positie sluiten) I never saw before. They are all of the kind of the one you see at the bottom, be it loss or be it profit (4th attachment shows an example with _C and profit, but that can be loss just the same).The 2nd attachment shows it is an in-bar trade (bars are 1 minute). See the down and up red and green arrows.
Backtesting does not exhibit this. See the blue up arrow in the preceding bar.I use no mechanism whatsoever that is capable of trading in- and out within the same bar. Still that happened here.
The “Close position” text should be leading to the issue.
Did anyone ever see that text and knows what it means ?Can @B&L perhaps see a similarity with his issue ?
10/28/2022 at 9:42 AM #203140Time has passed and IG is blaming PRT, PRT is blaming IG but clients still loose money on a issue that should not occur…
I ran into another one and this time I saw it happening. If I had to say who is to blame, I’d say PRT;
What I notice anyway is that limit orders (which is what this is about) tend to move along with the price change for a small second. This is not always visible and I suppose it depends on the movement of the price of the moment, but in this case I saw this happening :
The order is to be a Short and it is positioned as a Limit. The price rises/drops and the order is “taken” (I don’t say “filled” this time, deliberately, because I can’t tell). At the moment the order is taken (the position label is present now), the price moves up (rises) again, but the Limit order is still there (!!!) and it also moves up. It feels as another Limit order (but there is no second order ID that I can see so this should not be the case), and it thus has to be the same Limit Order which has gotten a second life and when the movement stops (thus within one second somewhere) that order is filled (too ?) but with an inverted action (this will be anomaly somehow).
Again, I saw this happening. Thus :
– Limit for Short is taken (label with position is there);
– Limit order is still there and moves up with the price, which price will have gone up, gone down (this takes the Short) and up again;
– Limit order thus moves up (looks like trailing) and within the second it’s “released” and that causes another order (position has now gone).
– Result : a small loss because of the price going in the wrong direction plus spread.NOTICE : The movement of the Limit order looks the very same as a Market order waiting to be filled. Thus, place Market order manually, and if it takes a while before it is filled, it moves with the price.
THEN : Because it is a soft order (Limit orders always need to be repeated each bar – of 1 minute in my case), PRT will deal with it as a Market order (I bet you).
Lastly : because the communication with IG may be too slow (I have seen this dozens of times going wrong with PRT-IB), PRT is waiting for confirmation while in reality the order has been filled already. PRT does not know this (yet) and thus moves the now Market order along with the price. After the feedback of IG, … something goes wrong.PS: I have dozens of open tickets with PRT-IB about very similar (if not the same) manual situations with PRT-IB. They result in double orders/positions, because you the user can’t see what is happening. This goes like :
– You place a Limit and this just disappears (but under the hood it is filled);
– You place a new Limit, and this may also disappear. Anyway after a while of waiting, you have two positions instead of the intended one position.
– Me, myself and I determined this definitely as a PRT problem because the communication with the broker is amiss (waiting for Broker-feedback is not dealt with properly).
I just called IG for the explanation of the “Positie sluiten” (Close position) text and at this moment we are as far that it is indeed the broker doing this.
Later today I will be called with the reason of it. That is, this is the intention of IG. I’ll keep you posted.1 user thanked author for this post.
-
AuthorPosts