Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Changing profit target with entry price

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Changing profit target with entry price


    I have a strategy that has a profit target of 4 ticks from the entry price.

    I want the profit target to automatically change to 4 ticks from the average entry price if I add another position to it.

    For example

    1st entry: 4000
    Initial profit target: 4001

    2nd entry: 3900
    New average price: 3950

    Profit target should change to 3051.

    Thanks!
    Last edited by Ousher; 10-06-2021, 10:55 AM.

    #2
    Hi, thanks for posting.

    To detect exactly when an execution happens use OnExecutionUpdate and change your profit target to the price: Position.AveragePrice + TickSize*4
    Order entryOrder; //assigned in OnOrderUpdate

    OnExecutionUpdate:

    if (entryOrder != null && entryOrder == execution.Order)
    {

    if (execution.Order.OrderState == OrderState.Filled)
    targetOrder = ExitLongLimit(0, true, execution.Position.Quantity, Position.AveragePrice +TickSize*4, "", "");

    }

    We have a more robust example of using OnOrderUpdate/OnExecutionUpdate here:


    Kind regards,
    -ChrisL

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    46 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    66 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X