Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetProfitTarget variable in Wizard

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

    SetProfitTarget variable in Wizard

    I use the Wizard and would like to have a setprofittarget level depending on a variable.
    Under conditions and actions/Do the following I specify:
    Variable4=KeltnerChannel(1.5,10).Lower(0)
    Then under Stops and Targets I specify:
    SetProfitTarget("Short".CalculationMode.Price,Vari able4)

    So I want a target for the short depending on the price level of the lower Keltner band at that moment. All the time I get a target equal to entry level. If I specify Calculation.Mode ticks then I get the same result: Target level equal entry level.

    Question: How can I implement in the Wizard the scenario where my target is set depending on a variable (in this case reflecting the level of the lower Keltner band as target for the trade).

    #2
    Hello Westvleteren,

    You would not be able to use a Variable0-9 for the Price of your Profit Target inside of the Strategy Wizard the way it is designed. You may use it as a "Tick" or "Percent" using the Variable.

    Since you are seeing this when you tried to change it to "Tick", can you confirm that you press the Finish button after making this change and tried to "Reload your NinjaScript" Strategy?
    JCNinjaTrader Customer Service

    Comment


      #3
      Hi JC,
      I use for the strategy action
      Variable4=KeltnerChannel(1.5,10).Lower(0) the following:
      Input series DefaultInput
      Offset multiplier 1.5
      Period 10
      Plot Lower
      Bars ago 0
      Offset type Ticks
      Offset 0
      Plot on chart True
      The at Stops and targets I use.
      SetProfitTarget("Short". CalculationMode.Price.Variable4)
      The following:
      From Entry signal Short
      Mode Ticks
      Value Variable4
      I then press compile and next until I see Finish and press finish
      On the chart I remove the strategy and click apply.
      Then I select the strategy, new, apply.
      Set enabled to True and press apply.
      I still get the result that target level is entry level.

      Comment


        #4
        Hello Westvleteren,

        You would not be able to use a Variable0-9 for the Price of your Profit Target inside of the Strategy Wizard the way it is designed.

        You will need to unlock your Strategy to be able to set your Profit Target order to a price using a Indicators value.

        For example.

        protected override void Initialize()
        {
        // Set Profit Target by default to 20 ticks.
        SetProfitTarget("", CalculationMode.Ticks, 20);
        }

        protected override void OnBarUpdate()
        {
        if(Position.MarketPosition == MarketPosition.Flat)
        {
        // Reset Profit Target.
        SetProfitTarget("", CalculationMode.Ticks, 20);
        }

        // Condition set 1
        if (Close[0] < Open[0])
        {
        Variable0 = KeltnerChannel(1.5, 10).Lower[0];

        // Set Profit Target to the Variable0
        SetProfitTarget("", CalculationMode.Price, Variable0);
        EnterShort(DefaultQuantity, "");
        }
        }

        You Condition of course may be different, but you may switch it to what you are currently using.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC,

          You mention price in your reply.

          "You would not be able to use a Variable0-9 for the Price of your Profit Target inside of the Strategy Wizard the way it is designed."

          I assume the same is true for ticks and percent?

          Is there any alternative how I can have a SetProfitTarget in the Wizard whereby the targetlevel varies according to a value (either price, tick or percent) of an indicator? The value of the indicator indicates then the target for that trade at that moment e.g. where the lower band of the Keltner is at that moment.

          Comment


            #6
            Hello Westvleteren,

            Yes, that is correct the same would apply for all of them.

            The only way you may have a Users Defined Input and then use that User Defined Input for a the targeted level.

            So instead of Variabe0-9 it would be a variable that you define and can set in the Strategy Parameters.
            JCNinjaTrader Customer Service

            Comment


              #7
              Hi JC,
              Thanks for helping me out and explaining how Ninja works.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by argusthome, Yesterday, 10:06 AM
              0 responses
              17 views
              0 likes
              Last Post argusthome  
              Started by NabilKhattabi, 03-06-2026, 11:18 AM
              0 responses
              16 views
              0 likes
              Last Post NabilKhattabi  
              Started by Deep42, 03-06-2026, 12:28 AM
              0 responses
              14 views
              0 likes
              Last Post Deep42
              by Deep42
               
              Started by TheRealMorford, 03-05-2026, 06:15 PM
              0 responses
              9 views
              0 likes
              Last Post TheRealMorford  
              Started by Mindset, 02-28-2026, 06:16 AM
              0 responses
              38 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Working...
              X