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 AaronKoRn, Yesterday, 09:49 PM
        0 responses
        11 views
        0 likes
        Last Post AaronKoRn  
        Started by carnitron, Yesterday, 08:42 PM
        0 responses
        10 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Yesterday, 07:51 PM
        0 responses
        12 views
        0 likes
        Last Post strategist007  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,982 views
        3 likes
        Last Post jhudas88  
        Started by rbeckmann05, Yesterday, 06:48 PM
        0 responses
        10 views
        0 likes
        Last Post rbeckmann05  
        Working...
        X