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
  • General Statistics

    • Total Topics
      21,170
    • Total Posts
      90,690
    • Total Members
      41,274
    • Most Online
      7,522
      10/06/21 10:53

    Newest Member
    toshendra
    Joined 27/01/23 19:31
  • Posts

    • I am a beginner, and I must say, there are a lot of rules to the trading game that one must abide by if they want to be successful.   Here, the writer mentions several basic rules for day vs swing trading.  However, I find that often times, the reasoning for these rules is not as  obvious for a beginner as it may be for an expert.   The 'why' factor if I may. For example, why must you have a large capital to trade with as a day trader? Because your positions must be large so that a small change in price will be augmented and turned into a large profit. Also, with such high risk, the margin will be specially high, given the trader is taking up large positions at a time.  Without a large amount of capital, positions may be forced to close due to funds being below margin requirements.  When this happens, you can expect to lose tons of cash, fast.  I learned the hard way. All the best, David Franco      
    • USDJPY has been regaining ground this week, but inflation differentials and a three-month trend signal the potential for another turn lower Source: Bloomberg      Joshua Mahony | Senior Market Analyst, London | Publication date: Friday 27 January 2023  USDJPY set for third monthly decline The USDJPY pair has been on the slide since its October high, with the historical 147.63 resistance level ultimately marking the end of the dramatic 21-month rally that saw the pair gain almost 50%. Much of that came through a period that saw US inflation soar as Japanese prices remain subdued. That disparity remains, but the direction of travel has certainly shifted as US CPI declines and Japanese price growth gradually ticks up. The overnight 4.3% figure for Tokyo core CPI represents a four-decade high, with the nationwide figures likely to follow on. The chart below highlights how USDJPY has been heavily correlated with the now tightening gap between US and Japanese inflation. However, it is more evident when shifting that inflation differential forward by seven-months. That close correlation highlights the potential for further downside as long as prices continue to trend in a similar manner. Source: ProRealTime Looking at the daily chart, the recent rebound has taken price up towards the top-end of a descending channel and Fibonacci resistance. This highlights the bearish pattern that has been playing out, with lower highs and lower lows in place in recent months. Unless we see price rise through trendline and 134.77 resistance, another turn lower looks likely for this pair. Source: ProRealTime
    • @MongiIG Hi - You recently covered Long NICKEL Trading the Trend and A. Rudolf did this morning but I see it is Closing only. Please clarify, Thanks D600
×
×
  • Create New...