Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating a strategy with single entry and multiple profit targets.

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

    Creating a strategy with single entry and multiple profit targets.

    Hello!

    I have been messing around with my strategy and have made progress, but have run into a snag.

    The underlying of my strategy is to have one entry point, and to scale out of a position. I had an ATM strategy that did this but want to use something similar to it in my strategy. It seems that is not possible to import the ATM but I made something similar in my strategy.

    So what I had to do is actually create two entries at the same time to each order one contract on the NQ
    Each of those entries has a unique ID Long1, and Long2. And each of them has a correlated Stop Loss, and profit target.

    They have the same stop loss and they have different exit parameters. One will exit sooner if it goes south, the other will have a longer leash.

    Here is how the Bones look:


    else if (State == State.Configure)
    {
    SetStopLoss(@"long1", CalculationMode.Ticks, 35, true);
    SetStopLoss(@"long2", CalculationMode.Ticks, 35, true);
    SetProfitTarget(@"long1", CalculationMode.Ticks, 35);
    SetProfitTarget(@"long2", CalculationMode.Ticks, 80);

    (Strategy goes here)

    {
    EnterLongLimit(Convert.ToInt32(1), (GetCurrentBid(0) + (-1 * TickSize)),@"long1");
    EnterLongLimit(Convert.ToInt32(1), (GetCurrentBid(0) + (-1 * TickSize)),@"long2");
    entrySubmit = true;

    if (CrossBelow(Close, SMAF, 1))
    {
    ExitLong((1), "SLongSma", "long1");
    }
    if (CrossBelow(Close, Bollinger1.Middle, 1)
    ExitLong((1), "SLongBB", "long2");

    NOW HERE IS THE ISSUE:

    Often times My strategy will enter and the first long will exit to protect profit. and then soon after get the signal to enter the position again., But only for one more contract.This is creating too many entries for me and a lot of noise I do not want.

    My entries per direction is set to 2, and my StartBehavior = StartBehavior.WaitUntilFlat;

    Then why is it that My Strategy still will enter my long1 position again over and over while I still have my long2 position open that has not been closed yet?

    Is there anyway so that I can make sure it does not enter any more trades until my Long2 has stopped out or reached its profit target? Or is there any other way I can code this to make it work ?

    Thanks for any help.

    Cheers,

    Tim
    Last edited by cryptochef; 10-13-2018, 08:09 AM. Reason: nq, strategy, entry, exit, multiple entries, multipleentries, help

    #2
    Hello Tim,

    Thank you for your note.

    You could set entries per direction to 1 and set Entry Handling to Unique Entries since you are uniquely naming your entry signals. This will allow each unique entry to be taken.

    See Entry Handling,


    There are several ways to prevent entry 1 triggering again before entry 2 to has been closed. It may be easiest to check that you are in a position of flat before either entry is submitted.

    You could use the if statement at the following sample to check that you are flat,


    Or if using a multi instrument script you could use,

    if(Positions[0].MarketPosition == MarketPosition.Flat && Positions[1].MarketPosition == MarketPosition.Flat)
    {
    //Do Something.
    }



    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X