Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Automatically Changing a Stop based on the Instrument being traded

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

    Automatically Changing a Stop based on the Instrument being traded

    I am adding a bunch of Stop layers to my Strategy. Many of those stop layers are based on levels on the chart from an Indicator and thus knowing the Symbol is not important.

    However, one or two of the Stop layers will need to know the Symbol of the Position as the calculation will be different. For Example, NQ and MNQ I might want to change the stop if the trade is up 50 points but for ES and MES I might want to do the same if up 8 points.

    - I know I can just make a Strategy for Each Symbol and just use the appropriate Strategy per chart. (i.e. have 10 strategies - one per symbol)
    - I know I can also make Parameter fields that you choose before adding the Strategy to the Chart (one time setup)

    BUT I am wondering how to create the Strategy so that it reads the Instrument Position symbol and automatically decides what to do - so that I just create ONE Strategy that works on all the symbols (NQ, MNQ, ES, MES, YM, MYM, RTY, M2K and CL). Trying to make it completely "set it and forget it" rather than 9-10 Strategies with the only difference being the numbers below or the Parameter settings.

    Example code:

    This would be NQ or MNQ.......I want to replace the "200" and "40" in the code so that for example ES and MES would automatically be 32 ticks and 8 ticks respectively.

    // Once NQ or MNQ price is greater than entry price + 200 ticks, set stop loss to 10 points
    if (Close[0] > Position.AveragePrice + 200 * TickSize)
    {
    SetStopLoss(CalculationMode.Price, Position.AveragePrice + 40 * Ticksize);
    }

    I could not find any posts on this kind of thing.
    Last edited by BigT4X; 07-11-2022, 10:35 AM.

    #2
    Hello BigT4X,

    You would need to write some custom logic for this.

    The Instrument (or Instruments collection if there are multiple series added) is where you can identify what instrument is selected.

    For example

    int tickDistance = 32;

    if (Instrument.MasterInstrument.Name == "MES")
    {
    tickDistance = 8;
    }


    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    44 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    124 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    65 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