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 post
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 post

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 post
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
Link to post

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
×
×
  • Create New...