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

Setting Profit and Loss

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

    Setting Profit and Loss

    Is there a way in Strategy Builder to create a Profit Target in ticks the same as Stop Loss after the Stop Loss has been set using an indicator?

    Example: SetProfitTraget = SetStopLoss(Value)

    Thank you.

    #2
    Hello Trader17,

    Thanks for your post.

    Dynamically setting Profit Target and Stop Loss are not possible through the Strategy Builder. If you set up a test that submits Profit Target/Stop Loss to indicator values, you will see that the profit target and stop levels do not change. I recommend setting up similar tests so you can learn more through experimenting.

    Demo - https://drive.google.com/file/d/1P7V...w?usp=drivesdk

    If you want to have the profit target/stop loss submit to differing levels, I recommend writing your own logic in Conditions and Actions that uses the Exit methods. Please refer to the Managed Approach documentation for reference on how these order methods should be used and to also reference any internal order handling rules you may encounter when creating strategies with the builder.

    Additionally, the Set methods do not have a return value and should be handled like methods instead of variables, so doing "SetProfitTraget = SetStopLoss(Value)" would be invalid.

    Managed Approach - https://ninjatrader.com/support/help...d_approach.htm

    If you would like to unlock the code and set stop loss and profit target levels that change throughout the life of the strategy, please refer to the reference sample below.

    Modifying Target and Stop - https://ninjatrader.com/support/help...of_stop_lo.htm

    Please let us know if you have any additional questions.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thanks for the video. I am not looking for dynamic stops or targets that are moving constantly. All I want is to see what the number of ticks an indicator comes up with for the stop and use th same number of ticks for the profit target.
      Thank you.

      Comment


        #4
        Hello Trader17,

        Setting a profit target and a stop loss with the same distance will require you to configure the profit and stop in the same fashion. It would not be possible to set a stop loss with some value and tell the builder to "use the same distance for the target."

        You could take an approach similar to the SampleOnOrderUpdate strategy to pick up on the value of your stop loss, subtract it from the current price, and then to submit an order for your profit target that distance. This requires unlocking the code, however.

        SampleOnOrderUpdate - https://ninjatrader.com/support/help...and_onexec.htm

        Monitoring Profit and Stop - https://ninjatrader.com/support/help..._and_profi.htm

        Please let us know if there is anything else we can do to help.
        JimNinjaTrader Customer Service

        Comment


          #5
          So basically it can be done but needs to be coded. Something like Set Profit Target to ( Entry Price - Stop Loss, tics) if Stop loss is derived from an indicator. Am I right? Maybe a future enhancement to Builder to have it in there?
          Thank you.

          Comment


            #6
            Hello Trader17,

            Yes, it could be done in code but needs to be programmed following the examples provided in my last post.

            We could not put in a request for supporting "SetProfitTraget = SetStopLoss(Value)" as this would be invalid syntax and the Builder cannot generate invalid syntax.

            In the Builder you can have the profit target and stop loss submitted to the same distance: Simply add a SetProfitTarget and SetStopLoss with CalculationMode.Ticks and the same variable for the value.

            Since the Builder places SetProfitTarget() and SetStopLoss() in State.DataLoaded, these levels are set before the strategy and indicator process data. Because of this, and as we saw in the demo, these values are not updated as the strategy takes new trades. The request you are looking for would be to use SetProfitTarget() and SetStopLoss() in OnBarUpdate() so you can assign price levels for your next target and stop before a new position gets entered. This has more to do with using indicator values for valid targets and stops in the Builder, but would also allow you to update the stop loss dynamically when the position is entered.

            The feature request ticket ID for this request is SFT-3342 and I have submitted a vote on your behalf. We cannot offer an ETA or promise of fulfillment, but we are tracking interest and the ticket ID number will be noted in the help guide when a new build gets released with the feature implemented.

            Release Notes - https://ninjatrader.com/support/help...ease_notes.htm

            Please let me know if there is anything else I can do to help.
            JimNinjaTrader Customer Service

            Comment


              #7
              Thank you very much.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Barry Milan, Today, 10:35 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by WeyldFalcon, 12-10-2020, 06:48 PM
              14 responses
              1,427 views
              0 likes
              Last Post Handclap0241  
              Started by DJ888, Yesterday, 06:09 PM
              2 responses
              9 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              40 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Today, 08:51 AM
              2 responses
              16 views
              0 likes
              Last Post bill2023  
              Working...
              X