minimum distance for this market is x
Forums › ProRealTime English forum › ProOrder support › minimum distance for this market is x
- This topic has 26 replies, 6 voices, and was last updated 11 months ago by ashehzi.
-
-
12/15/2023 at 6:15 PM #225293
Hi,
I got an auto trading algo and last night, it reported below and then got stopped.
“The order level you have requested is too close to the market level. The minimum distance for this market is 10.”
How can we make sure in the code that this doesn’t happen?
Regards,
Ash
12/15/2023 at 6:32 PM #22529512/15/2023 at 7:43 PM #225301It is not about the stop loss. Let me elaborate.
12345IF NOT LONGONMARKET AND TIMEOPERATE AND (BARINDEX > 400) AND (ordersCount < maxOrders) AND LongCondition THENBUY 1.0 CONTRACTS AT myLevel limitSET TARGET PLOSS minStopLossSET TARGET PPROFIT minProfitENDIFps. I’ve used “set stop ploss xx” also and the result is same
My min stoploss is more everytime e.g. in this case, it was 30. I don’t use 10 or even 20 for dax.
May be there is another problem. When my code leaves a limit order, there is generally no limit or stop put by broker. It gets added after the above order is executed. See attached. Somehow stoploss and takeProfit get added only once limit order is executed
12/15/2023 at 9:51 PM #22530412/16/2023 at 1:55 AM #225308I only trade via limit orders. I’m sure buy at market would have worked.
It’s 2am when the issue happened, 1h candle just closed near that 16750 and IG rejected the limit order as minimum 10 point difference between current price and my limit order value. As its dax and market is thin at night, that could be the reason. My question was how to avoid it. Is there a way to find minimum distance between current price and limit order level.
Thanks.
12/16/2023 at 9:54 AM #22531012/16/2023 at 11:19 AM #225318Is there a way to find minimum distance between current price and limit order level.
Sadly, No.
I year or so ago I talked this through with PRT support, and I-forgot-how-or-what but what came from that talk is that IG has this (dynamically changing) data, and could theoretically pass it on to PRT. I never heard back from that. However :One of the “solutions” springing from there, is what you see below. This tells as much as the PRT server not actively looking at (monitoring) the trade-desires of your System, at times it is bound to fail anyway. This is in the hands of PRT themselves, thus without the necessary cooperation of IG. But this is at 22:20 (Amsterdam) or so and is in virtual dead time. You 02:00 (03:00 Amsterdam) is no dead time at all, for the DAX.
It will (obviously) be spread related (IG lists that per instrument so you might have a look for that *if* the DAX has fixed spreads per day periods anyway).
What I did prior to that “Not Monitor” state feature, was creating a dead zone myself (don’t trade during that hours). Once you know it will fail anyway in a certain period, you could do that too. For the DAX I would think that your virtual dead zone may end at 06:00 (your time), so nothing much will happen at night. Personally I would exclude the opening from that and accept the larger distance (10 points ?) for that moment and for the first 5-10 minutes.
Another solution, which you are not asking for, is accepting the Market Order after all. I myself lately tend to solve things via this means, because it could net be the better solution (depends on your time in the market and whether your desired profit exceeds the spread largely anyway).I can imagine that @justisan has readily working ideas about this.
1 user thanked author for this post.
12/16/2023 at 12:41 PM #225325I agree, the close was just within the level my strat had i.e. it closed within 10 points from DAX 16750.2. Generally 10 points is a lot but it was that time of the night. I generally trade myself only RTH hours when doing so manually. For the code of FX, and indices, I had them starting at 0100 am GMT (London time). Probably that works for FX and for DAX, I may have to move to 5am start time. But there was move of 100+ starting from that time. Even running with a smaller size doesn’t hurt while you sleep.
12/16/2023 at 12:43 PM #22532612/16/2023 at 4:33 PM #225345To account for distance, the above code by ashehzi should be changed to:
123456789101112ONCE Distamce = 10 * pipsize //10 pip-distanceIF NOT LONGONMARKET AND TIMEOPERATE AND (BARINDEX > 400) AND (ordersCount < maxOrders) AND LongCondition THENIF close >= (myLevel + Distance) THENBUY 1.0 CONTRACTS AT myLevel limitELSIF close <= (myLevel - Distance) THENBUY 1.0 CONTRACTS AT myLevel STOPELSEBUY 1.0 CONTRACTS AT Market //you may want to comment this line out if you prefer to wait for the next candleENDIFSET TARGET PLOSS minStopLossSET TARGET PPROFIT minProfitENDIF12/18/2023 at 11:49 AM #225379Hi @ashehzi
I have never heard about a minimum distance on limit orders, I know that with IG there is a minimum distance for a Stop Loss or a Trailing Stop but for limit orders?
I think your problem is in your “Stop Loss”…
What I would do is, use the “normal” (IG) Set Stop Loss and keep the Stop Loss and the Take Profit out of the “If-Then” and use the IG option to adjust your Stop Loss to the current minimum distance…
12/18/2023 at 2:23 PM #225388thanks Peter for mentioning me 😀
though I have to say I did not find ever the exact solution for what Ash is asking – I did not find so far a way to identify via PRT code the “current” minimum distance between current price and intended order level. my answer is so far same as Peter’s – “no, there is no such way”. today I would add – even if there would be a way, it would not help, at least not me. the issue is not really that there is no such way, the issue is that IG deliberately invents and changes those minimum distances, instead of securing/providing the liquidity to the customers.
yes, there are some ways how to deal with “minimum distances” issue – some work-arounds in order to still make an algo trigger trades according intended conditions. adapting the code (possibly changing it at the same time to a multi time frame code, entries being generated at very, very small time frame, like 1 sec) so it works – as Peter mentioned – with ‘at market’ oders instead of entering positions with stop or limit is probably the most practical way. ideal / customer friendly solution it is definetely not. by itself the fact that IG’s “quants” determine whenever they need those minimum distances for entries/exits by whatever amount of points (sometimes small and sometimes hysterically huge) tells really a lot about their business model, and in general about what kind of “market” CFDs unfortunatelly are.
if one runs algos which trade relatively/very frequently and perform with relatively high hit rate / relatively low profit per trade compared to the risk, then the above issue probably drags not so much on trading outcome. my core algos generate just few trades per week and operate with hit rates which are < 40% (down to 15%), so I have to rely on that every single intended position is in fact taken, I cannot afford IG shutting down my algos multiple times per week due to those suddently appearing “minimum distances”… this is definetely one of major reasons, why I am transferring those algos to futures contracts, since PRT finally offered that possibility. thank you so much, PRT! 😀
12/18/2023 at 2:32 PM #225389ok, I have to add – like JS – that I was as well not aware that IG has minimum distances for entries with “limit” orders. simple explanation: I simply never enter positions via limit orders (but via stop orders mostly)… for entries with stop orders they definetely have and some times really huge ones – from time to time, mainly around the time when major economical data is being realeased (so kind of almost every day you have such cases) or some “big” central banks announce their interest rates decisions…
12/18/2023 at 11:19 PM #225403Minimum distance is in relation to placing a limit order. My stoploss and target profit are way far e.g. 30 points in that dax trade so no way it was that issue. The issue I’ve noticed also when trading manually is that sometimes IG doesn’t allow you to place an order too close to the market price stating your order is too close in a moving market. It does allow at market price, but not a limit order too close to the market price in spreadbet/cfd.
12/18/2023 at 11:27 PM #225404If you trade against the prevailing direction, how would a stop order work? I trade against the direction e.g. if the market is in downtrend and if it bounces to my level, i short it with a limit order and vice versa for uptrend. Now, how would I use stop order in this case?
-
AuthorPosts
Find exclusive trading pro-tools on