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 Jonafare, 12-06-2012, 03:48 PM
        5 responses
        3,986 views
        0 likes
        Last Post rene69851  
        Started by Fitspressorest, Today, 01:38 PM
        0 responses
        2 views
        0 likes
        Last Post Fitspressorest  
        Started by Jonker, Today, 01:19 PM
        0 responses
        2 views
        0 likes
        Last Post Jonker
        by Jonker
         
        Started by futtrader, Today, 01:16 PM
        0 responses
        8 views
        0 likes
        Last Post futtrader  
        Started by Segwin, 05-07-2018, 02:15 PM
        14 responses
        1,792 views
        0 likes
        Last Post aligator  
        Working...
        X