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();
    }

    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



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

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by mishhh, 05-25-2010, 08:54 AM
        19 responses
        6,189 views
        0 likes
        Last Post rene69851  
        Started by gwenael, Today, 09:29 AM
        0 responses
        4 views
        0 likes
        Last Post gwenael
        by gwenael
         
        Started by Karado58, 11-26-2012, 02:57 PM
        8 responses
        14,830 views
        0 likes
        Last Post Option Whisperer  
        Started by Option Whisperer, Today, 09:05 AM
        0 responses
        2 views
        0 likes
        Last Post Option Whisperer  
        Started by cre8able, Yesterday, 01:16 PM
        3 responses
        11 views
        0 likes
        Last Post cre8able  
        Working...
        X