Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Need help in collecting orders data

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

    Need help in collecting orders data

    Hi.

    I'm trying to collect data on my trades in the strategy ...(during run-time)

    So I want that every time an order is closed (due to close order or SL/TP):
    I'll be able to collect data about the trade:
    1. what is the PNL
    2. how many bars ago was the order entry.

    I tried to play with the "OnExecutionUpdate" and "OnPositionUpdate"
    but without success,

    please advice
    thanks
    Gil

    #2
    this is the (ugly) solution I found so far:
    protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
    {
    // Remember to check the underlying Order object for null before trying to access its properties
    if (execution.Order.OrderAction == OrderAction.BuyToCover || execution.Order.OrderAction == OrderAction.Sell || execution.Order.OrderType ==OrderType.Limit || execution.Order.OrderType ==OrderType.StopMarket)
    {
    Print("Exit, Entry price="+Close[BarsSinceEntryExecution()+1]);

    return;
    }

    if(execution.MarketPosition == MarketPosition.Long){
    Print("long close="+Close[0]);
    }
    if(execution.MarketPosition == MarketPosition.Short){
    Print("short close="+Close[0]);
    }

    }

    Comment


      #3
      Hello,

      Thank you for the post.

      Yes, in general, this should work, you could also store the CurrentBar when you submit the Entry, and then subtract that value from the CurrentBar at the time of the Execution to get a BarsAgo. While you are in a position, it would be suggested to use BarsSinceEntryExecution.

      Regarding the PnL, you could calculate this yourself using the entry and exit information or you could also review the trade performance collections: http://ninjatrader.com/support/forum...ead.php?t=4084

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by AlgoDreamer, Today, 12:39 PM
      2 responses
      8 views
      0 likes
      Last Post AlgoDreamer  
      Started by ninza33, Today, 12:31 PM
      1 response
      4 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by nleitman, Yesterday, 11:46 AM
      17 responses
      45 views
      0 likes
      Last Post nleitman  
      Started by tradingnasdaqprueba, Today, 03:42 AM
      7 responses
      32 views
      0 likes
      Last Post NinjaTrader_Jesse  
      Started by kaywai, Today, 11:59 AM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Erick  
      Working...
      X