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 Target always equals to a defined stop (1:1 Risk Reward)

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

    How to set Target always equals to a defined stop (1:1 Risk Reward)

    How to set Target always equals to the stop (1:1 Risk Reward) and Stop is define by an indicator and is not a static value?
    Also want to add a runner which stop will shift to break even after the target gets hit. But have no clue how to add those conditions on the strategy builder wizard.
    I'm new to NT and have no knowledge of coding. I just tried using strategy builder but got stuck here.

    #2
    Hello hijam999, thanks for your post.

    It depends on what kind of value you are getting from the indicator. You can not use the SetStopLoss or SetProfitTarget for this since the stop and target price are dynamic based on an indicator.

    Instead, use the ExitLong orders to submit the stop and target. I attached an example that uses the Bollinger. You must set Order Fill Resolution to High in the strategy settings to get this to work.

    Please let me know if I can assist any further.
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Only the Stop is based on an indicator but target will be based on the Stop i.e, Entry price minus Stop price will determine the target price.
      For example: Let us say I'm trading a swing breakout (long side) and I will keep the recent swing low as the stop. So the target will the same value as the stop above the entry.
      Let us say: x = entry price - stop price, then entry price + x will be the target.

      I got stuck here.

      Comment


        #4
        Hi hijam999, thanks for your reply.

        Regrettably, that type of arithmetic must be done with unlocked code. In the builder, you can not do arithmetic between two variables to use in another variable. An example modification of the original example I posted would be written as:

        Code:
        // Set 1
        if (Position.MarketPosition == MarketPosition.Flat)
        {
            EnterLong(Convert.ToInt32(DefaultQuantity), "");
            SetStops = true;
        }
        
        // Set 2
        if (Position.MarketPosition == MarketPosition.Long)
        {
            ExitLongStopMarket(Convert.ToInt32(DefaultQuantity ), Bollinger1.Lower[0], "", "");
            double x = Position.AveragePrice - Bollinger1.Lower[0];
            ExitLongLimit(Convert.ToInt32(DefaultQuantity), Position.AveragePrice + x, "", "");
            SetStops = false;
        }
        Please let me know if I can assist any further.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        19 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        20 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X