ProRealCode - Trading & Coding with ProRealTime™
hi Peter,
don’t really know what to tell more specific, above mentioned happened on the very real account with very real money 😀 today in the morning and my algo did not try to turn position from long to short, just another exit order with stop level had to be placed by algo closer to breakeven and that one was rejected, and system stopped by that rejection, with the comment in the order-list: ” The order was rejected for the following reason: Your funds currently available … EUR are insufficient to cover the total margin of … EUR that would be required on your account to place this order. Note : total margin takes into account any already open positions and/or existing pending orders.”
so I am a bit lost, I understood that every pending order is “reserving” some margin, not just margin required to keep a position. as mentioned, I have alsmost double amount in the account vs what’s needed to keep position overnight. strange enough, after re-activing the algo, another trades were triggered, and none of them were closed because of same reason as above but according intended/coded rules. but still all of them were having 2 exit stop orders (not just one), similar like this one currently open which you can see in the printscreen attached. strange, and not funny, because I don’t understand if what happened is “my fault” or did something go wrong with IB execution in the morning.
also what I still don’t know is if my orders, especially those for covering the position, are “real” orders at the exchange, or just “synthetic” orders kept at IB’s site until indicated levels to cover the position are touched. any clue how to verify that? you are mentioning “pending orders” and “fixed orders” – what do you mean by those?
regards
justisan
trying again to attach the pic…
what IB with futures does: it keeps the first exit order and places a second stop order – with the consequences that it requires/reserves addtional margin: this kicked me out immediately out of the trade due to unssuficient cash on the account.
Could you please send a console ticket through the help menu of the platforme please? We’d like to investigate in this, thank you 🙂
you are mentioning “pending orders” and “fixed orders” – what do you mean by those?
A Pending order it an order which needs to be repeated each new bar. If you don’t repeat it, it will be discarded at the end of the bar it was initiated in.
A “fixed” order (per my own terms) would be one of the kind of Set Stop $Loss (and its variations).
also what I still don’t know is if my orders, especially those for covering the position, are “real” orders at the exchange, or just “synthetic” orders kept at IB’s site until indicated levels to cover the position are touched.
There’s also the PRT part in this, and this is more vague (for me). So PRT itself knows about your margin, but adjusts the actuality of it with an unknown lag. Also, PRT intelligently tries to prevent you running you into a margin call, and if I am right an example of that is the from 1000 long to 1000 short situation which PRT judges in advance of the broker (IB). Don’t pin me down on this.
Would it be correct that the Stop order at the bottom of your picture implies ~3375 loss ? This seems much to me (if my math is correct in the first place) and your problem could be there to begin with.
That something would be added here (for total possible loss) would be wrong (your top-most selling stop order would be making profit (or break-even I think) so it can’t add to losses.
What I am thinking of now is this :
sell at initialstoploss stop // exit A
and then afterwards, depending on conditions which appear on the market/price development / this order has to be adjusted/increased to let’s say to breakeven level:
if onmarket and conditionsmet then
sell at breakevenlevel stop // exit B
endif
If literally done like that, then the condition for the first Stop order is missing (both Sell commands should be in a mutual exclusive If/Esle). So the first will still apply when the second later becomes active (ConditionSet becoming True).
Please notice that I myself am doing these things all over the place, but I take very good care of redundancy and the mutual exclusiveness I just talked about. Never anywhere would emerge the situation that two subsequent order commands are executed. And Yes, IB will deal with this differetly than IG because with IG all sorts of combinations are allowed, while IB just … errors out (well, not “out” really – no wait, it does 😉 ).
Notice that “IB” would merely be PRT which does not anticipate IB very well, as there is way insufficient experience, still (in de AutoTrading department). This is most probably why Nicolas asks you to send this Technical Report (you’d need to send your code to PRT as well).
I have learned to find backdoor solutions to these kind of anomalies, assumed it is an anomaly indeed. In this case it may look like double the amount for the Stop order, which is sent to the broker, but very maybe the lowest Stop order in your screenshot also lowered for price (my mentioned 3375 which seems high for 1 piece (contract)).
But first things first; cause your code to never execute two subsequent orders (also not opposite). Never think that the one will overrule the other. To this regard I see this passing by daily, and it is all over wrong :
If ExitCondition then
Sell at Market
ExitShort at Market
endif
Don’t do that because the situation that both occur or are required can’t exist (hey, with IG it very theoretically can, but never in the given out of context example like I just gave).
In your case (of obviously an also out of context example) :
If OnMarket and Not InWinningMood then
// Set SL nicely low but not too low and do this with Set Stop xLoss (x can e.g. be $).
// But If/Else this again for Long vs Short if you use a Pending Order (Sell/ExitShort m Contracts at $$$ Stop)
endif
// ...
If OnMarket and InWinningMood then
// Set SL to breakeven and again do this with Set Stop xloss
// But If/Else this ... etc.
endif
Hope this helps …
Peter
hi Peter,
thanks for your feedbacks. not always understanding them right away, but I hope I will at some moment. anyway (pissed quite heavily and ) still working all the time to figure out what what IG/IB differences are, since partiallialy they are really significant, same code – guite different execution by IG/IB. makes little sense.
regards
jutisan
what IB with futures does: it keeps the first exit order and places a second stop order – with the consequences that it requires/reserves addtional margin: this kicked me out immediately out of the trade due to unssuficient cash on the account.
Could you please send a console ticket through the help menu of the platforme please? We’d like to investigate in this, thank you 🙂
2″”
I will sure not open any ticket on the case precisely mentioned with the real data and code. PRT does not investigate on anything if one does not share the code, and even if sharing the code – in last approx 10 year I never, really never ever received a feedback (even “promissed”) on the issues for which I opened a ticket in the last approx 10 years. this is really sad but true. I would really like everybody to learn from each other, but I do/did not learn anything from PRT/IG (because of completely missing feedback on tickets) except that they do what they do and I have to find the solution on my own based on that.I have to figure out with my money what they are really doing and how they are they are doining their business.
Wow.
justisan, I have been reading this 4 times in order to understand it is not a quote from my own thoughts. I refrained from telling exactly this in my last post because I thought it was too negative.
Very special.
And so much more the truth of the (sad) real life with PRT.
All what I left of these thoughts was this :
I have learned to find backdoor solutions to these kind of anomalies
because nothing gets solved anyway, and *if* it is solved, you will not be notified. But please notice : if we don’t report these things, we don’t give PRT *and* ourselves the opportunity to solve things to begin with.
anyway (pissed quite heavily and ) still working all the time to figure out what what IG/IB differences are, since partiallialy they are really significant, same code – guite different execution by IG/IB.
All I can say is : don’t hesitate to open topics with dedicated questions regarding this. There won’t be many people with the experience on both IG and IB, but at least I am one and I will grab all I can in order to learn myself. Nothing, really nothing executes the same (always broker related and not really PRT-bug impeded) and we can only find out by trial and error. This obviously costs money in itself. You don’t want to know …
Heads up,
Peter
hi Peter,
I am considering advantages and disatvantages of reporting / not reporting the issues I face – and I still don’t see any sense in opening tickets today: after arround a decade of experience I was „forced“ to conclude that in the end I have to figure out on my own exactly those “backdoor solutions” you mention. So basically almost no tickets any more. and so yes, that is my “negative” feedback – from which our service providers could learn if they would like to. but there is even one very positive side related to to experience mentioned: I am kind of pushed to simplify my codes even more than initially intended 😀 so I can detect more easy and precisely what works according my intention and what not. in order to give PRT/IG, me and other traders the opportunity to solve things I still sometimes (like 1x per year) open a ticket – but not with algos I trade live, yet creating some different algo and including there real parts of code (from live algo) which I suppose are failing/creating issues, running them live with smallest position possible until failure occurs and then reporting – and then sharing code as well. while knowing I will never receive any relevant feedback. Nobody will tell me what the issue really is, they will not notify about solution being implemented (like you mention) etc.. solution might come in 6 months or in a year – while I have to deal with specific issues “today”. And my issue with now transiting to futures is that it is much more expensive to run tests just in order to detect failures, compared to cfds where you can experiment live with ultra-low position sizes and have mistakes/failures which cost you few euros. and one has to test everything live, because lot of failures do not show up in backtest mode at all.
I am not telling that issues I face are always service providers‘ fault – frequently enough they are my own mistakes, or rather “misunderstandings” about how PRT/IG works with my codes in the live mode vs. backtests. Yet now when I thought I have learnt a lot/enough in the past years, this current move to futures is quite a challange (punch in the face!), as mentioned: same code with significant differences in the execution on cfd vs futures and there is nobody at PRT to tell what the core differences are and how to work around them. So again lot of fun, I am moving forward, not losing my optimism yet, not now at least 😀
one has to test everything live, because lot of failures do not show up in backtest mode at all.
There is a 3rd option … Live data using ProOrder on a Demo Account.
Do you have a Demo Account? In the past I have asked this and members have said, what is a Demo Account?
UPDATE, NEW INSTRUMENTS AVAILABLE
Hello,
We have activated the following futures for IB Auto Trading:
EURUSD, EEURUSD, MEURUSD, NG
Dears,
After few months of experience transferring from cfds to futures some of my automated strategies which I run on dax index, I would like to share my obeservations, pros and cons which I faced on futures trading vs cfd trading. I leave aside the fact that exactly same code is not necessarily executed exactly same way on cfds with IG and on futures with IB: this I would not call pro or con – one just has to figure out those differences and adjust the code.
I hope that nobody takes it as “ultimate truth” what I tell below, and definitely it is not a complete list. these are just my impressions after very few months of development and live trading, which might be wrong in the end, after having more experience. In fact I hope that some of those traders reading my lines will come and tell “what a nonsense!” and share their different observations. I also don’t want to “advertise” rather to trade futures than cfds (or vice versa…). Both have remarkable advantages and disadvantages. Anyway, analyzing how same strategies “behave” with cfds vs futures is a huge source of inspiration for me, enormous learning opportunity.
So here you go, with my pros and cons of futures trading vs cfd:
Pros:
Cons:
Regards
justisan
Hi Justisan,
Thank you for your informative insight, I can endorse almost all your points…
About the costs, when you look at the price of a futures contract and the price of the underlying assets, for example an index, that difference in points is the cost you pay for the future. On the way to the expiration date of the future, the difference in points will decrease and on the expiration date, the price of the future will be equal to the underlying assets.
Automated trading with Interactive Broker and ProRealTime – NOW AVAILABLE
This topic contains 136 replies,
has 31 voices, and was last updated by
robertogozzi
2 months, 2 weeks ago.
| Forum: | ProOrder: Automated Strategies & Backtesting |
| Language: | English |
| Started: | 01/26/2023 |
| Status: | Active |
| Attachments: | 23 files |
The information collected on this form is stored in a computer file by ProRealCode to create and access your ProRealCode profile. This data is kept in a secure database for the duration of the member's membership. They will be kept as long as you use our services and will be automatically deleted after 3 years of inactivity. Your personal data is used to create your private profile on ProRealCode. This data is maintained by SAS ProRealCode, 407 rue Freycinet, 59151 Arleux, France. If you subscribe to our newsletters, your email address is provided to our service provider "MailChimp" located in the United States, with whom we have signed a confidentiality agreement. This company is also compliant with the EU/Swiss Privacy Shield, and the GDPR. For any request for correction or deletion concerning your data, you can directly contact the ProRealCode team by email at privacy@prorealcode.com If you would like to lodge a complaint regarding the use of your personal data, you can contact your data protection supervisory authority.