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 FrazMann, Today, 11:21 AM
        0 responses
        3 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        10 responses
        36 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        24 views
        0 likes
        Last Post DayTradingDEMON  
        Started by George21, Today, 10:07 AM
        1 response
        19 views
        0 likes
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X