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

SetStopLoss doesn't work with "fromEntrySignal"

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

    SetStopLoss doesn't work with "fromEntrySignal"

    Hello, if I use SetStopLoss only with two parameters (CalculationMode mode, double value) it woks correctly. But if I use SetStopLoss with four parameters (fromEntrySignal, CalculationMode mode, double value, bool isSimulatedStop) the stop order is fixed in a incorrect level. I have made a lot of tests checking this issue. How can I solve it? Thanks in advance.

    #2
    Hello soyjesus,

    Thanks for your post.

    Please provide a reduced example script and the steps to replicate, that demonstrates the issue you are observing.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Paul,

      Thank you for your help. This mi code:

      a) SetStopLoss(EtiquetaEntradaCorta, CalculationMode.Ticks, Ticks_StopMax, false);

      b) SetStopLoss(CalculationMode.Ticks, Ticks_StopMax);

      The variable "EtiquetaEntradaCorta" is a string with the name of the strategy and the currentbar.

      The variable "Ticks_StopMax" is a double.

      Comment


        #4
        Hello soyjesus,

        Thanks for your reply.

        I am asking for a working strategy that has only the code used to demonstrate the issue and the steps to recreate the issue (Instrument, bar type, time frame, Live/replay/strategy analyzer).

        Thanks in advance.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks for your reply. I'm trying to find the issue with a new code more simplificated.

          Comment


            #6
            Hello soyjesus,

            Thanks for your reply.

            From your original description, I suspect the issue is related to the string name used so you may want to verify the entry order name exactly matches the entry name used in the SetStopLoss.


            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hello Paul,

              The issue continues. I attach a sample. When I use "SetStopLoss" without fromEntrySignal name, it works ok. But when I use the parameter "fromEntrySignal name" it doesn' work.

              Thanks in advance for your help.

              Attached Files

              Comment


                #8
                Hello soyjesus,

                Thanks for your reply.

                In your example, you are already assigning a setstoploss order in the same block where you are placing the enter long order. Later you are trying to add another setstoploss with the order name but this will not work because the first setstoploss is in place and only one stoploss per order is possible.

                Here is an example of how you use signal names:

                if (EntryConditions are true)
                {
                SetStopLoss ("MySignalName", CalculationMode.Ticks, 20, false); // always set the stop/profit values first to ensure they are ready
                SetProfitTarget("MySignalName", CalculationMode.Ticks, 20);
                EnterLong("MySignalName");
                }

                if (conditions to adjust the stoploss)
                {
                SetStopLoss("MySignalName", CalculationMode.Price, Low[0] - 5 * TickSize, false);
                }
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Ok, but I need to change the level of stop-loss when the price reach a level. So I need to begin with a level stop and after to change this level. How can I do it?

                  Comment


                    #10
                    Hello soyjesus,

                    Thanks for your reply.

                    The example I showed in Post #8 starts with a stop loss at 20 ticks from the entry. Then I adjust the stop loss (when "conditions to adjust the stoploss" becomes true) to a price based value of the Low[0] price - 5 ticks.





                    Paul H.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by rexsole, Today, 11:48 AM
                    1 response
                    3 views
                    0 likes
                    Last Post NinjaTrader_PatrickG  
                    Started by jeronymite, Yesterday, 05:05 PM
                    3 responses
                    50 views
                    0 likes
                    Last Post NinjaTrader_ChristopherJ  
                    Started by Don22Trader1, Yesterday, 05:54 PM
                    3 responses
                    45 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Started by Jebulay, Today, 08:36 AM
                    1 response
                    38 views
                    0 likes
                    Last Post NinjaTrader_PatrickG  
                    Started by ShayeAus, Yesterday, 09:09 PM
                    4 responses
                    68 views
                    0 likes
                    Last Post bltdavid  
                    Working...
                    X