Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Name of stoploss or profit target for multiple entry orders?

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

    Name of stoploss or profit target for multiple entry orders?

    I have a strategy that submits 3 entry orders with 3 different order names. For example, I may submit one long entry with name "LONG ENTRY 1", a second with name "LONG ENTRY 2" and a third with name "LONG ENTRY 3". I submit these using EnterLongStopMarket(Pos1Size, longEntryPrice, LONG_ENTRY_1_NAME) etc.

    Inside OnOrderUpdate I can set the proper Order object based on the order entry name. So now I have

    Order longEntry1, longEntry2, longEntry3, shortEntry1, shortEntry2, shortEntry3

    When the order is filled, inside OnOrderUpdate I can detect that by checking if (execution.Order.OrderState == OrderState.Filled) for each of my orders.
    When that happens, I want to set the stoploss and profit targets for those orders using SetStopLoss and SetProfitTarget functions. These acceptthe name of the ENTRY order. There seems to be no way to set the name of the stoploss or profit target order itself.

    Inside OnOrderUpdate, I also wantto check to see if a stoploss order or take profit order was rejected. For example, if a stoploss order is rejected, I should exit everything. The problem is that the only way I know of to check if the current order is a stoploss order is to use the order name. I knw that NT hardcodes the stoploss order name for single entries as "Stop loss" and "Profit target". But what if I have multiple entry orders? Are all stoploss and profit target orders just given the name "Stop loss" and "Profit target"? How can I differentiate between the stoploss for a given entry order?

    #2
    Hello westofpluto,

    When the order is filled, inside OnOrderUpdate
    just as a note here, any filled logic that generates orders (entry fills, stops submit) generally should be placed in OnExecututionUpdate.
    https://ninjatrader.com/support/help...ghtsub=onorder
    •For triggering actions such as the submission of a stop loss order and target order using custom OCO logic when your entry order is filled, we recommend working directly in OnExecutionUpdate() instead.

    For finding the rejected orders in OnOrderUpdate you could check if the orders name equals Stop loss and its FromEntrySignal == "theEntryName" to determine which stop or target it was.
    https://ninjatrader.com/support/help...lightsub=order



    Please let me know if I may be of additional assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by kaywai, Today, 06:26 AM
    1 response
    6 views
    0 likes
    Last Post kaywai
    by kaywai
     
    Started by ct, 05-07-2023, 12:31 PM
    6 responses
    203 views
    0 likes
    Last Post wisconsinpat  
    Started by kevinenergy, 02-17-2023, 12:42 PM
    118 responses
    2,780 views
    1 like
    Last Post kevinenergy  
    Started by briansaul, Today, 05:31 AM
    0 responses
    10 views
    0 likes
    Last Post briansaul  
    Started by traderqz, Yesterday, 12:06 AM
    11 responses
    28 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Working...
    X