• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to set 2 Profit Targets

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

    How to set 2 Profit Targets

    Hi, I'm trying to find out how to build my strategy with 2 target. 1 exiting at 50 ticks and another only if Price Close below SMA 10.

    Could anyone give some hints? Thanks.
    Here is my code below:

    {
    SetProfitTarget("", CalculationMode.Ticks, Target);
    SetStopLoss("", CalculationMode.Ticks, StopLoss, false);

    CalculateOnBarClose = true;
    }

    protected override void OnBarUpdate()
    {
    // Condition set 1
    if (Close[0] > SMA(SMA10)[0] && myBool)
    {
    EnterLong(DefaultQuantity, "");
    myBool = false;
    }

    #2
    Hello john_robertson00,

    Thank you for your post.

    Is the 'Target' used in your SetProfitTarget() the 50 tick profit?

    For the CrossBelow() you can use the following code:
    Code:
    if(CrossBelow(Close, SMA(10)))
    {
    ExitLong();
    }
    Patrick H.NinjaTrader Customer Service

    Comment


      #3
      Hi Patrick, Thank you for the reply. Correct. Right now I have this code working as:
      once price closes above SMA 10, I enter 1 contract long and only exit if StopLoss or TargetProfit is hit.

      I'm trying to test entering 2 contracts to this strategy and having both contracts with the same StopLoss but 2 Targets. Currently I have SetProfitTarget() coded but this will exit both contracts at 50 ticks.

      I'm not sure how to add 2 ProfitTargets. What you suggested is what I'm looking for, but where do I add that to the code?

      Comment


        #4
        In this case you will want to use different signal names for your entry so you can have different targets and stops for each (even if the stops are at the same level)

        Change EnterLong(DefaultQuantity, "");
        to something like this (please adjust the quantity as desired, as this will place two orders)

        EnterLong(DefaultQuantity, "Order1");
        EnterLong(DefaultQuantity, "Order2");

        Then for your stops/targets do something like this

        SetProfitTarget("Order1", CalculationMode.Ticks, Target1);
        SetStopLoss("Order1", CalculationMode.Ticks, StopLoss, false);
        SetProfitTarget("Order2", CalculationMode.Ticks, Target2);
        SetStopLoss("Order2", CalculationMode.Ticks, StopLoss, false);


        When you run the strategy, in order to get both trades to fire you will need to change your entry settings to UniqueEntries, otherwise only the first will trigger: http://puu.sh/6jJK4.png

        http://www.ninjatrader.com/support/h...rdirection.htm

        Let me know if I can further assist.
        LanceNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Johnny Santiago, Today, 10:05 AM
        1 response
        10 views
        0 likes
        Last Post Johnny Santiago  
        Started by madhouse, Today, 09:44 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Spencer  
        Started by Matt17, Today, 09:38 AM
        2 responses
        6 views
        0 likes
        Last Post Matt17
        by Matt17
         
        Started by mikrodoctor, Today, 08:04 AM
        1 response
        11 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by lakman184, Today, 03:04 AM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_Jim  
        Working...
        X