Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unable to acquire ext price at target

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

    Unable to acquire ext price at target

    Once an ATM controlled strategy goes flat because it hit a target, it does not seem to be possible to find out the exit price. The following code gives an error message
    string[,] orders = GetAtmStrategyStopTargetOrderStatus("TARGET1", atmStrategyIdn[lim]);

    // Check length to ensure that returned array holds order information
    if (orders.Length > 0)
    {
    for (int i = 0; i < orders.GetLength(0); i++)
    {
    Print(CurrentBar + " upOrdS Target Status" +
    " target fill price is " + orders[i, 0].ToString() +
    " Qty " + orders[i, 1].ToString() +
    " state is " + orders[i, 2].ToString());
    }
    }
    Is there a workaround?
    Last edited by roland_nt; 03-30-2014, 11:55 PM.

    #2
    Hi Roland, you are correct this is a current known limitation, once the ATM strategy is terminated there would be no way to access this info.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      I'm capturing EntryPrice,EntryBar, ExitPrice,ExitBar. This has been running for a week OK, If the entry and exit occur on the same bar the code needs to run in OnMarketData(), if it can be guaranteed the entry and exit occur on separate bars then OnBarUpdate() is OK. I'm running 1 Order / Strategy, if you use multiple Orders/Strategy the approach should still work but coding would be more complicated.

      psuedoCode
      At OrderCreate
      {
      EntryPrice=0,EntryBar=0,ExitPrice=0,ExitBar=0
      }
      if(EntryBar=0){
      if(MarketPosition(StrategyId) !=Flat && GetAtmEntryOrderStatus(OrderId)==Filled) // Trade was filled this (Bar/Tick)
      { // Capture Entry Info
      EntryBar=CurrentBar;
      EntryPrice=GetAtmEntryOrderStatus; // Like your code
      }
      }
      if(ExitBar=0){
      if(MarketPosition(StrategyId) ==Flat && GetAtmEntryOrderStatus(OrderId)==Filled) // Trade was exited this (Bar/Tick)
      {
      ExitBar=CurrentBar;
      ExitPrice=Calculate Based on( Entryprice above plus GetAtmRealizedPnL)
      }
      }

      Comment


        #4
        Finding exit price of closed ATM strategy

        Very clever:
        Use entry price (which is known) and add realized PNL to it.
        Brilliant tquinn..
        A real head slapper.
        Thank you.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Jimmyk, 01-26-2018, 05:19 AM
        6 responses
        835 views
        0 likes
        Last Post emuns
        by emuns
         
        Started by jxs_xrj, 01-12-2020, 09:49 AM
        6 responses
        3,291 views
        1 like
        Last Post jgualdronc  
        Started by Touch-Ups, Today, 10:36 AM
        0 responses
        10 views
        0 likes
        Last Post Touch-Ups  
        Started by geddyisodin, 04-25-2024, 05:20 AM
        11 responses
        62 views
        0 likes
        Last Post halgo_boulder  
        Started by Option Whisperer, Today, 09:55 AM
        0 responses
        9 views
        0 likes
        Last Post Option Whisperer  
        Working...
        X