How to scale out of a position in two steps?

Forums ProRealTime English forum ProOrder support How to scale out of a position in two steps?

Viewing 9 posts - 1 through 9 (of 9 total)
  • #144915

    Hi,

    How can I scale out of a position in two steps? I want to sell the first half of my position at two times my initial risk and the second half I want to sell if I have two closes below the 8 Exponential Moving Average. The basic code (only part of the entire code) I want this two step exit apply to is below.

    Thank you.

    #144919

    Partial closure of positions is not allowed in real AutoTrading, only in bscktests.

     

    1 user thanked author for this post.
    #144920

    I assume I could open two separate positions and manage them independently, right?

    How do I do this? Just doubling the code? And how do I setup up the trailing stop?

    #144923

    You can accumulate positions (going the same directions), but you cannot keep them separate.

    There can only be one SL and one TP.

    The price is only one, POSITIONPRICE, an average price of the different TradePrices.

    To accumulate positions you need to use:

    then simply execute as many BUY or SELLSHORT you need.

    Countofposition will return the positive number of Long positions or the negative number of Short positions accumulated so far. You can use ABS() to make all of them positive.

     

     

     

    #144926

    Thank you!

    So it looks like the only way to create what I want (to optimize the profit ) is to have two separate accounts, one in which I use a fixed price target for the first position, and a second account where I can use a trailing stop loss.

    I hope ProRealTime will add this feature in future.

    #144930

    ProRealTime HAS this feature, unfortunately IG doesn’t!

    But we do all hope this will be supported.

    #144933

    I see. Thank you for clarifying.

    #144957

    looks like the only way to create what I want

    You can run 2 separate identical Algos on the same IG Account.

    If you are clever enough at coding you likely could use ‘simulated trades’ to determine when the  conditions in your first post are met and so have each Algo react accordingly?

    https://www.prorealcode.com/blog/learning/how-to-improve-a-strategy-with-simulated-trades-1/

    #144988

    Thank you GraHal! I’ll take a look at the article.

    The challenge is that it’s hard to know when a market is going to trend in a strong way so that a trailing stop loss is better to maximize profit, or when the market is just moving the average move and a fixed profit target is better.

    Another idea I had yesterday night is simply to have two separate identical Algos running in the same account with each having half the position size and one is having a fixed profit target and the other is using a trailing stop loss.

    1 user thanked author for this post.
Viewing 9 posts - 1 through 9 (of 9 total)

Create your free account now and post your request to benefit from the help of the community
Register or Login