Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

I get as much "Profit target" orders as my "Partially filled" orders

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

    I get as much "Profit target" orders as my "Partially filled" orders

    Hello NT Team,

    I'm facing a problem that is really breaking the entire logic behind my strategy, I noticed that when I send mid-size orders, like 15 or 30 contracts in quantity, the order is executed or multiple "Partial Fills", let's say 2 or 3, it this happens, then I get 2 or 3 "Profit target" and "Stop loss" orders that are having the same name ("Profit target" and "Stop loss") but they are having different order IDs.

    but according to my strategy, I Set the TP and SL only 1 time, and I made sure that it verifies the condition only 1 time, why do I get multiple profit targets ?

    for me if i send an order of 15 contracts and it got filled on 3 times, I want ONLY 1 TP and 1 SL orders with total executed after fully filled.

    This is the code I'm using :

    Code:
    if (myProfitOrder == null)
    {
    
    ProfitTargetLevel = Convert.ToInt32(TargetProfitLevel/TickSize);
    SetProfitTarget(CalculationMode.Ticks, ProfitTargetLevel);
    }
    
    if (myStopLossOrder == null)
    {
    
    StopLossLevel = Convert.ToInt32((ChosenATR+1)/TickSize);
    SetStopLoss(CalculationMode.Ticks, StopLossLevel);
    }
    plz, look at the attached image to see the problem


    #2
    Hello MohammedAmine,

    Thanks for your post.

    Do you have StopTargetHandling set to PerEntryExecution or ByStrategyPosition? This is typically set in OnStateChange under State.SetDefaults (Removing and re-adding the script is necessary for SetDefaults to be processed a new in the NinjaScript lifecycle.)



    We look forward to assisting.

    Comment


      #3
      yes it is already set to :

      Code:
      StopTargetHandling = StopTargetHandling.PerEntryExecution;
      *
      I changed to ByStrategyPosition ? and re run the strategy, it was resulting in TP and SL with double quantity of what I have open

      for example if I have 33 contracts open in a position, I get SL and TP with 66 as pending contracts, 66 in TP and 66 in SL
      Last edited by MohammedAmine; 10-01-2021, 11:16 AM.

      Comment


        #4
        Hello MohammedAmine,

        ByStrategyPosition would allow the stop and target to cover the position as a whole instead of individual entry executions, so if an entry is filled from partial fills, ByStratgeyPosition would make sure you have one order as opposed to multiple orders.

        I don't have enough details for how you are using the Set methods in your strategy, but their intention is to be called before the associated entry order is submitted because the Set methods prep NinjaTrader to submit target and stop orders when the entry order is seen as filled. You can see with the example attached, if there is a partial fill, the strategy only submits one target/stop for and updates it in the event of a partial fill.

        Modifying stop and target orders after you have entered is possible by calling the Set method again when you are in a position, and you cans see the example below for further demonstration.

        Sample Price Modification - https://ninjatrader.com/support/help...of_stop_lo.htm
        Attached Files

        Comment


          #5
          Thank you very much man, I really appreciate your permanent support

          you won't believe man, the doubling problem was coming out of the blue, i simply re-read the strategy a billion times, and I see no miss calling or twice calling the Set methods, I simply disconnected and re-connected and everything worked fine, I really dono, this is scary because it makes me feel like it needs as a must human intervention, and what if i work on real money of my clients, and i get the same problem out of nowhere, only because i need to disconnect and reconnect.

          now everything seems to work fine, i just want to ask you, do i need to change anything if i want to switch to Real account on dorman trading broker ?

          Thank you once again

          Comment


            #6
            Hello MohammedAmine,

            With the set methods, please be sure you are following the best practices as noted in post #4 (Call the set methods before you enter to be sure they are set at initial levels. Do not use a Set method for the purpose of placing orders after you see the execution of an entry order. These do not work like Exit methods.)

            If you want to run a strategy live, you just have to enable it against a live account. Please be sure to be familiar with the documentation pages below as well.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            44 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            65 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