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

Query regarding order position

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

    Query regarding order position

    Hello.
    I have an query. Suppose For BUY Side I am putting 3 entries one for Entry price(using EnterLongStop method), Profit Target Price(using ExitLongStop method) and Stoploss price( also usingExitLongStop method). Now suppose on the BUY side my profit target price achieved, So while calling on the method: if (Position.MarketPosition== MarketPosition.Short) ,will it be true ?
    If it is true, So I have to call CancelOrder method to Cancel The Stoploss price order or Profit target price, whichever is order exist?

    #2
    Hello smith1309,

    I would recommend placing the stop loss and profit target orders after the entry order has filled in OnExecution() or OnOrderUpdate().

    If the entry uses a signal name and the exit order's from entry signal matches the entry order's signal name, the exit is attached to that entry. If the entry is exited, this will cause any other attached exit orders that are still working to be cancelled automatically.

    However, you can optionally cancel these orders your self using CancelOrder with an order object.

    Below is a link to an example of placing a stop loss and profit target with ExitLongStop and ExitLongStopLimit.



    As a heads up, when an entry order is placed it needs time to be submitted, be accepted, become working, and then fill, and report this back to NinjaTrader. The position will not be changed until the order has gone through all of these states. This means that the Position.MarketPosition will not be changed immediately in OnBarUpdate when an order is placed. (However, it might be by the next bar).
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      So,If I am using OnExecution method to place stoploss and profitTarget orders. Is it such that whenever price reaches stoploss or ProfitTarget,then only order is filled and then excuted OR using OnExecution only to check entryprice has been filled and executed, and both stoploss and profitTarget are filled and waiting for triggering (execution)of both order?
      And if both stop and target orders are filled and one of them triggers then how to manage or cancel that?
      Any example will be helpful.

      Comment


        #4
        Hello smith1309,

        My apologies. The examples from my previous post are for NinjaTrader 8.
        The link below is to an example for NinjaTrader 7.


        The stop loss and profit target are submitted the moment the entry order fills in OnExecution().

        The opposing order is cancelled using CancelOrder().
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by frankthearm, Today, 09:08 AM
        7 responses
        28 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by NRITV, Today, 01:15 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by maybeimnotrader, Yesterday, 05:46 PM
        5 responses
        25 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by quantismo, Yesterday, 05:13 PM
        2 responses
        16 views
        0 likes
        Last Post quantismo  
        Started by adeelshahzad, Today, 03:54 AM
        5 responses
        33 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Working...
        X