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

OrderMethod/Onexecution

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

    OrderMethod/Onexecution

    Hey guys, when you meet a profit target in a trade using the statement, SetProfitTarget("Long 1a", CalculationMode.Ticks, profitVar);

    Lets say I want to change certain variables in the Onexecution method when the "Long 1a" trade meets its profit target and is sold, how do I know which position was sold in OnExecution?

    #region OrderMethod
    protected override void OnExecution(IExecution execution)

    #2
    You can call SetProfitTarget() throughout OnBarUpdate() to change the values used without needing OnExecution.

    When using OnExecution to track orders you would likely want to use IOrders to manage your position as opposed to calling the SetProfitTarget() method.

    That being said this is possible to call SetProfitTarget() from OnExecution()

    For an example of determining which order called OnExecution please see: http://www.ninjatrader.com/support/f...ead.php?t=7499
    LanceNinjaTrader Customer Service

    Comment


      #3
      Hi, thanks for the info, but when I use SetProfitTarget like

      SetProfitTarget("Long 1a", CalculationMode.Ticks, profit1);

      entryOrder1 = EnterLong(0, DefaultQuantity, "Long 1a");

      protected override void OnExecution(IExecution execution)
      {
      if(entryOrder1 != null)

      entryOrder1 comes up as NULL here for some reason, not sure why?

      Comment


        #4
        Do you have a sample script that replicates the error.

        It is possible OnExecution would get called when the entry order is null but this would depend on your logic. In otherwords you could be setting it to null somewhere else or a different order could be calling OnExecution
        LanceNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        4 responses
        12 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by terofs, Today, 04:18 PM
        0 responses
        11 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by nandhumca, Today, 03:41 PM
        0 responses
        7 views
        0 likes
        Last Post nandhumca  
        Started by The_Sec, Today, 03:37 PM
        0 responses
        3 views
        0 likes
        Last Post The_Sec
        by The_Sec
         
        Started by GwFutures1988, Today, 02:48 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X