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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    430 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    282 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    241 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    331 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    292 views
    0 likes
    Last Post CarlTrading  
    Working...
    X