Jump to content

Automatically move stop once when price drops below a level


Recommended Posts

Hi. I have a trading strategy that I would like to execute but it involves moving the stop once when the price drops below a set threshold. Example: 

  • Current EURUSD price is at 10,000 (easy numbers)
  • I put down a sell working order with the level set at 9,980 and a stop set at 9,990. The price drops to below 9,980 and the order is placed.
  • As soon as the price drops further to 9,960 or below, the stop is moved close to the current price, i.e. it is moved from 9,990 to 9,965
  • Note this is a once-off move and a trailing stop won't (I don't think) give me what I need
  • I monitor the price further and tap out if it reaches a lower profit taking level 

I am achieving this currently through another rest api process that watches the price every 1 minute and moves the stop when the threshold is hit, but I would like something more automated / on the platform itself as I often miss the intra-minute movements.  I have considered a streaming approach but this can't be set up for limit setting right?  Also considered using alerts but this is not (currently) part of the rest api.  Can I achieve the above using the current IG rest api tools or even 3rd party tools?  Thanks!

Link to comment
On 30/03/2021 at 17:35, wki said:

Hi. I have a trading strategy that I would like to execute but it involves moving the stop once when the price drops below a set threshold. Example: 

  • Current EURUSD price is at 10,000 (easy numbers)
  • I put down a sell working order with the level set at 9,980 and a stop set at 9,990. The price drops to below 9,980 and the order is placed.
  • As soon as the price drops further to 9,960 or below, the stop is moved close to the current price, i.e. it is moved from 9,990 to 9,965
  • Note this is a once-off move and a trailing stop won't (I don't think) give me what I need
  • I monitor the price further and tap out if it reaches a lower profit taking level 

I am achieving this currently through another rest api process that watches the price every 1 minute and moves the stop when the threshold is hit, but I would like something more automated / on the platform itself as I often miss the intra-minute movements.  I have considered a streaming approach but this can't be set up for limit setting right?  Also considered using alerts but this is not (currently) part of the rest api.  Can I achieve the above using the current IG rest api tools or even 3rd party tools?  Thanks!

I don't see why you couldn't use the steaming API to watch the price and the REST API to move the stop. 

If your problem is that you would like to act quicker between minutes just watch the price setting up the streaming service and then when the threshold is hit call the REST API to update the stop. You have already most of the work done.

Link to comment

Ok great, so I can use the streaming api for this.  Assuming I can do this over multiple forex pairs?  I have the streaming api working in that I have been able to print to screen in Python but have hit a bit of a block going beyond that, wasn't sure if it was possible. Any resources you can recommend on how to do this? I'll look myself but if you have anything at your fingertips, that would be 👍

Thanks!

Link to comment
1 hour ago, wki said:

Ok great, so I can use the streaming api for this.  Assuming I can do this over multiple forex pairs?  I have the streaming api working in that I have been able to print to screen in Python but have hit a bit of a block going beyond that, wasn't sure if it was possible. Any resources you can recommend on how to do this? I'll look myself but if you have anything at your fingertips, that would be 👍

Thanks!

You can subscribe to multiple epics with the streaming service, once you get your updates it will be per epic. You should hold a collection of epics and its prices in memory , then act on every price update.

1. Subscribe to prices. (Streaming service)

2. Subscribe to trades. (Streaming service)

3. Hold your positions locally in a collection (Get the first snapshot from the REST API)

4. Set your thresholds per epic in a another collection.

5. Wait for a price update (Streaming), on that update check your positions and thresholds. Once you reach a level call the Rest API to move the stop.

6. You will get an update from the Trades streaming service, update your positions collection in that update.

If you can share your code on Github I can have a look when you have something set up.

Edited by jlz
  • Like 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • image.png

  • Posts

    • Unlike many emerging platforms that are building a reputation, Safe is already a leading provider of smart wallet infrastructure for Ethereum and EVM blockchains and their focus is to transform every Ethereum account into a secure smart account. With over 200 projects already deployed on Safe's standard, including Gnosis Pay and Worldcoin, it boasts a vast ecosystem that enables new applications in DeFi, staking, gaming, and more. Widely used by individuals and organizations for features like gasless transactions, facial recognition logins, Safe is trusted by industry giants like Vitalik Buterin, Punk6529, Shopify, and Reddit for managing their digital assets. I believe with over 8.3 million Safe accounts, 47 million transactions processed, zero critical security incidents since launch in 2018 plus a slated Bitget listing of SAFE token, Safe is setting the industry benchmark for security. Who is/are Safe’s closest competitors?
    • Dow, Nasdaq 100 and Nikkei 225 make headway off recent lows The selling in indices has stopped for now, with major markets higher after finding at least a short-term low last week. Source: Getty Images Written by: Chris Beauchamp | Chief Market Analyst, London   Publication date: Tuesday 23 April 2024 13:38 Dow recovery goes on The index continues its recovery from the lows of last week, and Monday’s session saw it move back above the 100-day simple moving average. The flood of major earnings over the coming two weeks may mean that the index experiences a more volatile period, even if it does continue to rebound. Further gains target 39,000, which provided some resistance earlier in the month, and then on to 40,000. A close back below 38,000 could suggest the price will head back towards 37,500, retesting last week’s low. Source: ProRealTime Nasdaq 100 braces for big tech earnings The pullback in the index paused yesterday, as the price reached 17,000. A small gain helped to suggest that a low may be forming. The big tech earnings that dominate this week and next may mean that the index struggles in the short-term, though with the percentage of index members below their 20-day SMA hitting 5% last week a short-term bounce still seems likely. A close above 17,415 and the 100-day SMA helps to build a short-term bullish view. Sellers will want to see a close back below 17,000, which could then open the way to the January low at 16,177. Source: ProRealTime Nikkei 225 returns to 100-day SMA As with other indices, the Nikkei 225 has seen its pullback pause over the past three sessions. Buyers appeared last week when the index dropped below 37,000, and the index then pushed back to the 100-day SMA. A close above the 100-day SMA would add strength to the bullish view, while the price then targets the early April highs around 39,860. 37,000 continues to hold as support for now, so a break below here is needed to put the bearish view back on track. Source: ProRealTime
×
×
  • Create New...
us