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 PaulMohn, Today, 12:36 PM
                  2 responses
                  16 views
                  0 likes
                  Last Post PaulMohn  
                  Started by Conceptzx, 10-11-2022, 06:38 AM
                  2 responses
                  53 views
                  0 likes
                  Last Post PhillT
                  by PhillT
                   
                  Started by Kaledus, Today, 01:29 PM
                  0 responses
                  4 views
                  0 likes
                  Last Post Kaledus
                  by Kaledus
                   
                  Started by yertle, Yesterday, 08:38 AM
                  8 responses
                  37 views
                  0 likes
                  Last Post ryjoga
                  by ryjoga
                   
                  Started by rdtdale, Today, 01:02 PM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_LuisH  
                  Working...
                  X