Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy issue with multiple targets

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

    Strategy issue with multiple targets

    I think there is an error in 8.0.25.0 64-bit on strategy with multiple targets
    I develop a strategy with 2 entries, 1 stop and 2 targets

    if (State == State.SetDefaults)
    {
    Description = "Test2Targets";
    Name = "Test2Targets";
    Fast = 10;
    Slow = 25;
    // This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
    // See the Help Guide for additional information
    IsInstantiatedOnEachOptimizationIteration = false;
    SetOrderQuantity = SetOrderQuantity.Strategy;
    EntriesPerDirection = 2;
    StopTicks = 50;
    TargetTicks1 = 25;
    TargetTicks2 = 100;
    TraceOrders = true;
    }
    else if (State == State.Configure)
    {
    SetStopLoss(CalculationMode.Ticks, StopTicks);
    SetProfitTarget("MAcross1", CalculationMode.Ticks, TargetTicks1);
    SetProfitTarget("MAcross2", CalculationMode.Ticks, TargetTicks2);
    }

    entries on MA cross


    if (CrossAbove(smaFast, smaSlow, 1))
    {
    EnterLong(1, "MAcross1");
    EnterLong(1, "MAcross2");
    }
    else if (CrossBelow(smaFast, smaSlow, 1))
    {
    EnterShort(1, "MAcross1");
    EnterShort(1, "MAcross2");
    }

    both profit targets are with quantity 2, I would expect each profit target is with quantity 1

    strategy, trace and logs, screenshot attached

    Attached Files

    #2
    Hello Klaus Hengher,

    Thank you for your post.

    It's a simple fix actually, your strategy is set to use By Strategy Position for the Stop and Target Handling setting, which submits stops and targets to cover the entire position. Adding this line in State.SetDefaults should set that to Per Entry Execution by default so you get the right quantities:

    StopTargetHandling = StopTargetHandling.PerEntryExecution;

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

    Edit: I've also moved this to the more appropriate Strategy Development forum since it pertains to a NinjaScript Strategy.
    Last edited by NinjaTrader_Kate; 11-16-2021, 03:06 PM.

    Comment


      #3
      Hi Kate,

      thanks for your answer
      I added StopTargetHandling = StopTargetHandling.PerEntryExecution;
      But now I have different issue, after 2 trades theres is only 1 profit target order
      See details in attached zip
      Attached Files

      Comment


        #4
        Hello Klaus Hengher,

        Thank you for your reply.

        I'm not able to replicate the behavior I'm seeing on your chart with the strategy provided. If you test with Market Replay data over the same day and time with the Strategy, are you able to replicate this? If you remove and re-add the strategy to the chart does the behavior where only one profit target gets placed recur?

        Thanks in advance; I look forward to assisting you further.

        Comment


          #5
          I can reproduce with market replay speed 1, I think it's because partial fill on close position see screenshot (2 times Close Position with quantity 1)
          With speed 10 I couldn't reproduce issue
          Attached Files

          Comment


            #6
            Hello Klaus Hengher,

            Thank you for your reply.

            So I may best try to reproduce, at what time in Playback did the erroneous order occur? What time zone are you located in?

            Thanks in advance; I look forward to assisting you further.

            Comment


              #7
              Hallo Kate,
              The time zone in Germany is Central European Time
              Order at about 9:50 am (see on last screenshot )
              Thanks
              Klaus

              Comment


                #8
                Hello Klaus Hengher,

                Thank you for your reply.

                I've tested on my end and I'm not able to reproduce. Could you provide a screenshot of the settings you're using for the Strategy? Here's what I'm seeing with the default settings:

                Click image for larger version

Name:	2021-11-23_11-12-23.png
Views:	212
Size:	152.9 KB
ID:	1179416

                Thanks in advance; I look forward to assisting you further.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NullPointStrategies, Yesterday, 05:17 AM
                0 responses
                59 views
                0 likes
                Last Post NullPointStrategies  
                Started by argusthome, 03-08-2026, 10:06 AM
                0 responses
                133 views
                0 likes
                Last Post argusthome  
                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                0 responses
                73 views
                0 likes
                Last Post NabilKhattabi  
                Started by Deep42, 03-06-2026, 12:28 AM
                0 responses
                45 views
                0 likes
                Last Post Deep42
                by Deep42
                 
                Started by TheRealMorford, 03-05-2026, 06:15 PM
                0 responses
                50 views
                0 likes
                Last Post TheRealMorford  
                Working...
                X