Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Setting partial profit target

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

    Setting partial profit target

    Hi,

    I am looking to enter into a multiple-contract position and set a profit target for each contract separately in different places. However, I have not found a way to achieve this so far. The way that I have tried doing it was:

    Code:
    EnterLongLimit(ContractSize, limitPrice, orderName1);
    EnterLongLimit(ContractSize, limitPrice, orderName2);
    EnterLongLimit(ContractSize, limitPrice, orderName3);
    SetProfitTarget(orderName1, CalculationMode.Ticks, TakeProfitTickSizeFirst);
    SetProfitTarget(orderName2, CalculationMode.Ticks, TakeProfitTickSizeSecond);
    SetProfitTarget(orderName3, CalculationMode.Ticks, TakeProfitTickSizeThird);​
    I would appreciate some help to figure this out.

    Regards,
    Pouya

    #2
    Hello Pouya,

    Thank you for your post.

    You are on the right track by using separate entry signals and having separate SetProfitTarget() orders tied to each entry via fromEntrySignal. What were the results when you attempted this? Have you added debugging prints to print the value of each order name and the take profit tick sizes, and if so what were the results in the output? Were the values assigned as expected or do you see unexpected values that need to be modified?
    For more information about debugging tips:


    We have a reference sample that demonstrates scaling out of a position, similar to what you are trying to achieve, here:


    Please let us know if we may be of further assistance.

    Comment


      #3
      Hi,

      Thanks for the quick response.

      The problem seems to be the fact that I cannot submit the second and the thrid buy limit order. The following is the logs that I print from my strategy:
      Code:
      Enter Long At: 5021,25
      orderId='NT-00003-3344' account='Backtest' name='order 11' orderState=Submitted instrument='ES 03-24' orderAction=Buy orderType='Limit' limitPrice=5021.25 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-15 17:33:13' gtd='2099-12-01' statementDate='2024-02-15'
      orderId='NT-00003-3344' account='Backtest' name='order 11' orderState=Accepted instrument='ES 03-24' orderAction=Buy orderType='Limit' limitPrice=5021.25 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-15 17:33:13' gtd='2099-12-01' statementDate='2024-02-15'
      orderId='NT-00003-3344' account='Backtest' name='order 11' orderState=Working instrument='ES 03-24' orderAction=Buy orderType='Limit' limitPrice=5021.25 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-15 17:33:13' gtd='2099-12-01' statementDate='2024-02-15'
      TakeProfitTickSizeFirst: 8
      TakeProfitTickSizeSecond: 16
      TakeProfitTickSizeThird: 20
      orderId='NT-00004-3344' account='Backtest' name='Profit target' orderState=Submitted instrument='ES 03-24' orderAction=Sell orderType='Limit' limitPrice=5023.25 stopPrice=0 quantity=1 tif=Gtc oco='NT-00002-3344' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-15 17:33:13' gtd='2099-12-01' statementDate='2024-02-15'
      orderId='NT-00004-3344' account='Backtest' name='Profit target' orderState=Accepted instrument='ES 03-24' orderAction=Sell orderType='Limit' limitPrice=5023.25 stopPrice=0 quantity=1 tif=Gtc oco='NT-00002-3344' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-15 17:33:13' gtd='2099-12-01' statementDate='2024-02-15'
      orderId='NT-00004-3344' account='Backtest' name='Profit target' orderState=Working instrument='ES 03-24' orderAction=Sell orderType='Limit' limitPrice=5023.25 stopPrice=0 quantity=1 tif=Gtc oco='NT-00002-3344' filled=0 averageFillPrice=0 onBehalfOf='' id=-1 time='2024-02-15 17:33:13' gtd='2099-12-01' statementDate='2024-02-15'
      orderId='NT-00003-3344' account='Backtest' name='order 11' orderState=Filled instrument='ES 03-24' orderAction=Buy orderType='Limit' limitPrice=5021.25 stopPrice=0 quantity=1 tif=Gtc oco='' filled=1 averageFillPrice=5021.25 onBehalfOf='' id=-1 time='2024-02-15 17:33:13' gtd='2099-12-01' statementDate='2024-02-15'​
      As you can see there are no "order 12" and "order 13".

      Comment


        #4
        Ok, in the strategy analyzer, I had entries per direction set to 1, which is why the other entires were ignored.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        116 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        61 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        40 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        43 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        82 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X