Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

# of trades is 1 after ProfitTarget set as % instead of as ticks

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

    # of trades is 1 after ProfitTarget set as % instead of as ticks

    Hi NinjaTrader

    the title says pretty much averything.
    I realized that setting profit target/stop loss in ticks for stocks does not work. For now. So i switched them to %.

    profit target 10%
    stop loss 6%
    which makes sense (is realistic) for stocks

    So there should be more trades, but I only get 1 trade per each stock.

    What went wrong?

    Thanks

    #2
    What exact parameter value did you enter for your % stop and target then? Please ensure you enter 0.1 for a value of 10% and 0.06 for a value of 6%.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi Bertrand

      Thanks for your reply.
      Your suggestion does not work.
      I have unlocked the code:
      // Wizard generated variables
      private int profitTarget = 45; // Default setting for ProfitTarget
      private int stopLoss = 15; // Default setting for StopLoss

      protected override void Initialize()
      {
      SetProfitTarget("", CalculationMode.Percent, ProfitTarget);
      SetStopLoss("", CalculationMode.Percent, StopLoss, false);
      CalculateOnBarClose = true;
      }

      So looks good to me. What do you think?
      So then in the Backtest window of the Strategy Analyzer, when I try to set values as per your suggestion 0.06 or 0,06 or 6%, I get a message saying "Property value is not valid".

      Please explain how can I tell a thing to stop at 6%.

      Thanks

      Jonas

      Comment


        #4
        You would need to make the stoploss and target parameters a double value (you have it as Int now), so you could set your needed 6% for example (0.06).
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Hi Bertrand

          Thanks, I sorted out the decimals problem. However new questions occured.
          You suggested to use decimals for percentage targets/limits.

          Where do I need to put it:
          a) in the code?
          b) in the strategy analyzer's backtest window?
          c) both places?

          Also, when I enter 0.1 into b), NT automaticaly rounds it to the nearest integer
          (0.1 NT rounds to 1). Is there a way to stop that?

          Thanks!!

          Comment


            #6
            Just to clarify:
            I meant where shall I put it IN DECIMALS:
            a)in the code
            b)backtest window( btw it doesnt update automatically if I change values in the code)
            c) both places

            Comment


              #7
              The issue is that you have defined those as integer values -

              private int profitTarget = 45; // Default setting for ProfitTarget
              private int stopLoss = 15; // Default setting for StopLoss

              Those would need to be changed to type of double - the same would be true for your public properties that would define your user inputs. These should be of type double then as well. Compile the code then after your changes and you would be able to input the values as needed.
              BertrandNinjaTrader Customer Service

              Comment


                #8
                Bertrand

                This is done already. I have no problems putting it in decimals anywhere now. However, since my entries/exits act weird, I want to clarify:

                Where shall I put them IN DECIMALS:
                a)in the code
                b)backtest window( btw it doesnt update automatically if I update values in the code)
                c) both places

                thanks

                Jonas

                Comment


                  #9
                  Jonas, you want to enter your desired stop / target values then in the inputs, so the user interface, not hardcoded into the script.
                  BertrandNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by aligator, 01-06-2022, 12:14 PM
                  4 responses
                  235 views
                  0 likes
                  Last Post john_44573  
                  Started by reynoldsn, Today, 05:56 PM
                  0 responses
                  5 views
                  0 likes
                  Last Post reynoldsn  
                  Started by bortz, 11-06-2023, 08:04 AM
                  51 responses
                  1,990 views
                  0 likes
                  Last Post aligator  
                  Started by dmking, 11-12-2019, 12:31 PM
                  4 responses
                  4,150 views
                  0 likes
                  Last Post jasonw
                  by jasonw
                   
                  Started by roblogic, Today, 04:31 PM
                  0 responses
                  10 views
                  0 likes
                  Last Post roblogic  
                  Working...
                  X