Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    Emily C.NinjaTrader Customer Service

    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 Touch-Ups, Today, 10:36 AM
        0 responses
        5 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        8 responses
        61 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        4 responses
        3,289 views
        1 like
        Last Post jgualdronc  
        Started by Option Whisperer, Today, 09:55 AM
        0 responses
        5 views
        0 likes
        Last Post Option Whisperer  
        Started by halgo_boulder, 04-20-2024, 08:44 AM
        2 responses
        24 views
        0 likes
        Last Post halgo_boulder  
        Working...
        X