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

How to set "stop loss" and "profit target" based on account balance

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

    How to set "stop loss" and "profit target" based on account balance

    Hello All,

    I'm a newbie and trying the strategy builder. I want to set the stop loss based on a certain % of the account balance. Then, set the profit target according to a risk-to-reward ratio based on the stop loss. Is it possible to do that?

    Also, after connected to Interactive Brokers via NinjaTrader, how can I execute the trading strategy on IB TWS (paper and live)?

    Thank you!

    #2
    Hello Tommy60,

    Thanks for the post.

    What you described would be possible however only in manual coding. The Strategy Builder would not be able to calculate the percent of account or access account values.

    Regarding the other question, after connecting you would need to enable the strategy if you want to run it. You can do that by using a Chart and its Right click -> Strategies menu or from the control center Strategies tab. Your strategy has an account selection when you first configure it so that would be how to tell it to run on paper or live or Sim101 etc.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello Jesse,

      Thank you for the fast response!

      Would you mind offering help or providing resources for manual coding for the conditions above?

      And I can't even place a simple order on IB TWS via NinjaTrader. "Connected" is displayed at the bottom left corner.

      I have another question about setting Parabolic SAR when building trading strategies. Since Parabolic SAR does not have a value, how should I set up the conditions for entries or exits?

      Thank you very much!
      Last edited by Tommy60; 03-17-2021, 12:34 PM.

      Comment


        #4
        Hello Tommy60,

        I am not aware of a specific example of trading based on the percent of an account. That would essentially require that you define a starting amount variable in the script and then monitor the trades as they fill to recalculate the new values of the account remaining.

        If you are having difficulty placing manual orders I would suggest to first look into that before trying to do anything with scripting. NinjaScript relies on the remainder of the platform working correctly, if you have not correctly configured the connection or if there is something on the broker end holding up the orders that would prevent scripts from submitting orders.

        Have you at this point opened a support ticket for that concern? If not, what specifically happened when you submitted an order? Is there an error?

        For the parabolicSAR, it does have a plotted value which could be referenced from the builder. It only has a single plot so there would not be a drop down to select a plot, its just defaulted to the only plot it has. How you set up the condition depends on how you wanted to use that value toward your goal. You could plot the indicator on a chart as a starting point to get some ideas of the values it makes to better know how you may want to use that.



        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          NinjaTrader_Jesse

          Hello,

          I am trying to input a trailing stop loss that activates after 60 ticks and a stop loss from the start.

          I have inputted the two and they both work by themselves but when I try them together the stop loss works but the trailing stop wont activate.

          SetTrailStop("",CalculationMode.Currancy,60,false) ;
          ​​​​​​​SetStopLoss("",CalculationMode.Currenc y,5,f alse);

          What am I doing wrong?

          Comment


            #6
            Hello litamm89,

            SetTrailStop and SetStopLoss cannot be used at the same time. They are both targeting the same position so that could lead to a double exit for a single position. You would have to use one or the other.
            The alienate is to not use the Set methods for targets and just submit your own regular orders from OnBarUpdate as targets.

            I look forward to being of further assistance,
            JesseNinjaTrader Customer Service

            Comment


              #7
              NinjaTrader_Jesse

              Thank you that clears things up. What is OnBarUpdate?

              If that is the case is there a way I could set up a three tiered trailing stop that activates different stops once it hits different levels similar to what is on the ATM exit strategies?

              Comment


                #8
                Hello litamm89.

                OnBarUpdate is the main method that scrips use for processing your custom calculations.

                https://ninjatrader.com/support/help...ub=OnBarUpdate

                Setting up an exit like you described would be possible however that would require some of the more complex coding techniques.

                That would involve monitoring the filled orders/prices and modifying orders that you are observing when necessary.

                We have a sample that includes a break even, that would essentially be the same logic needed to do any target modifications at a later time.

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


                I look forward to being of further assistance,
                JesseNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by jclose, Today, 09:37 PM
                0 responses
                4 views
                0 likes
                Last Post jclose
                by jclose
                 
                Started by WeyldFalcon, 08-07-2020, 06:13 AM
                10 responses
                1,413 views
                0 likes
                Last Post Traderontheroad  
                Started by firefoxforum12, Today, 08:53 PM
                0 responses
                10 views
                0 likes
                Last Post firefoxforum12  
                Started by stafe, Today, 08:34 PM
                0 responses
                10 views
                0 likes
                Last Post stafe
                by stafe
                 
                Started by sastrades, 01-31-2024, 10:19 PM
                11 responses
                169 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X