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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    43 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    21 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    30 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    41 views
    0 likes
    Last Post CarlTrading  
    Working...
    X