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

Variable SL + TP - Strategy Coding - Risk Reward Ratio

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

    Variable SL + TP - Strategy Coding - Risk Reward Ratio

    Hello!

    I have tried around the strategy builder, however i cant find a way that allows users to input parameters such as Take Profit (TP) and Stop Loss (SL) as variables.

    Additionally, I'm interested in developing a strategy centered around the Risk-Reward (RR) ratio. This entails setting the Take Profit as a multiple of the Stop Loss, determined by an input variable, RR ratio. For instance, TP would equal SL multiplied by RR ratio. Could you advise on how to implement this within the strategy builder?

    I've tried searching the forum, however all I found was the generic "The Strategy builder can't do that. You have to do it yourself", but i can't find how to do it myself. Any help would be greatly appreciated.

    Thank you.
    ​​

    #2
    Hello Vietanhnguyen2hotmailcom,

    For your question about using variables for the targets, you can do that by creating Inputs in the builder. When you configure the targets the value would be set by hovering the mouse over the value field and click Set. Then select the user input you wanted to use.



    For your second question that is possible but not with the strategy builder. In manual coding you can get or set the ratio in the tool, there is an example that shows drawing the tool and using the Ratio property here: https://ninjatrader.com/support/help...k+reward+ratio


    JesseNinjaTrader Customer Service

    Comment


      #3
      Hey Jesse,

      thanks for the quick answer. I realize i haven't been specific enough with my issue.

      What I'd like to do with the Strategy Builder is to make an algo. It would look at the last few candles (lets say last 5 candles) exactly the entry happens and determine the lowest point. Then, it should calculate the tick distance between Entry and and the lowest point of the past 5 candles and use this value as SL.
      Afterwards, using a custom RR ratio, for the sake of ease, lets say 2, it should determine TP.

      So, TL;DR example of a Long entry:
      1. (Long)Entry
      2. Look at the lowest point of the past 5 candles.
      3. Calculate the distance from entry to this point.
      4. Use this tick size as SL.
      5. Multiply this tick size by 2, use it as TP.
      I have everything for my entry conditions ready already. Just having issues with SL and TP.

      Thanks a lot again!

      Comment


        #4
        Hello Vietanhnguyen2hotmailcom,

        You can do math in the builder if you wanted to calculate a value and save it to a variable. You can also dynamically price targets however both of these concepts are a little more complex when using the strategy builder. You would not be able to use ticks as an input for the order so you would need to make a calculate which results in a price to be able to do that in the builder. If you only can calculate into ticks that would need to be done in manual coding.

        You can find a sample of dynamically pricing targets here: https://ninjatrader.com/support/foru...rategy-builder


        JesseNinjaTrader Customer Service

        Comment


          #5
          is there any way i could use an EMA line value at the time of entry as the SL, and a 2x RR ratio as TP?
          Just knowing this would probably solve 95% of all my coding issues.

          Ive read through all 11 pages of the above mentioned link, and sadly it wasn't very helpful to me :/

          Comment


            #6
            Hello Vietanhnguyen2hotmailcom,

            The EMA can be used that way from the builder, you cannot use drawing objects in that way from the builder. The sample that I linked to could be modified to use an indicator. Instead of setting the Close price to the stops variable you would set an indicators price. If you are looking at the trailing stop example set 2 is where you would do that. The CurrentStopPrice variable is set to the close plus an offset, you could use the ema in place of close.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by rbendson, Today, 08:18 PM
            0 responses
            2 views
            0 likes
            Last Post rbendson  
            Started by TheTechnician86, Yesterday, 05:47 PM
            2 responses
            18 views
            0 likes
            Last Post TheTechnician86  
            Started by bigc0220, 09-18-2018, 09:16 AM
            8 responses
            2,615 views
            0 likes
            Last Post bsteeze
            by bsteeze
             
            Started by bortz, 11-06-2023, 08:04 AM
            54 responses
            2,113 views
            0 likes
            Last Post rene69851  
            Started by DawnTreader, 05-08-2024, 05:58 PM
            24 responses
            104 views
            0 likes
            Last Post DawnTreader  
            Working...
            X