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 futtrader, 04-21-2024, 01:50 AM
        6 responses
        57 views
        0 likes
        Last Post futtrader  
        Started by sgordet, Today, 11:48 AM
        0 responses
        1 view
        0 likes
        Last Post sgordet
        by sgordet
         
        Started by Trader146, Today, 11:41 AM
        0 responses
        2 views
        0 likes
        Last Post Trader146  
        Started by jpapa, 04-23-2024, 07:22 AM
        2 responses
        17 views
        0 likes
        Last Post rene69851  
        Started by funk10101, Today, 11:35 AM
        0 responses
        1 view
        0 likes
        Last Post funk10101  
        Working...
        X