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 geddyisodin, Today, 05:20 AM
        2 responses
        16 views
        0 likes
        Last Post geddyisodin  
        Started by hazylizard, Today, 08:38 AM
        0 responses
        6 views
        0 likes
        Last Post hazylizard  
        Started by Max238, Today, 01:28 AM
        5 responses
        42 views
        0 likes
        Last Post Max238
        by Max238
         
        Started by giulyko00, Yesterday, 12:03 PM
        3 responses
        13 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by habeebft, Today, 07:27 AM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_ChristopherS  
        Working...
        X