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

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.
    Kate W.NinjaTrader Customer Service

    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.
        Kate W.NinjaTrader Customer Service

        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.
            Kate W.NinjaTrader Customer Service

            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:	167
Size:	152.9 KB
ID:	1179416

                Thanks in advance; I look forward to assisting you further.
                Kate W.NinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by quicksandatl, Today, 11:11 AM
                2 responses
                6 views
                0 likes
                Last Post quicksandatl  
                Started by GwFutures1988, 10-15-2023, 12:13 AM
                12 responses
                517 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Started by DawnTreader, Yesterday, 05:58 PM
                3 responses
                16 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by OllieFeraher, Today, 11:14 AM
                3 responses
                5 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by aman jain, 10-01-2020, 09:25 PM
                3 responses
                294 views
                0 likes
                Last Post Legiboka  
                Working...
                X