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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    47 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    23 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    33 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    51 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X