Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Capture Avg Cost of multiple positions

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

    Capture Avg Cost of multiple positions

    I often have multiple trades running at the same time, often going in both directions (long & short). The trick of course is to take the shorts out at lows and the longs out at highs....but additionally I MUST know exactly where my average cost is, so that at the very least I take longs out above and shorts out below the avg cost line.

    I want to code an indicator that tracks the average cost of manually entered orders,
    (entry Price factored by # of contracts)....and then simply prints it on the screen.
    My questions are....
    1. Where do I capture the entry price /# of contracts for a manually
    entered order?
    2. Where do I capture the fact that all orders have been filled...at which point
    I reset the average cost back to "0" (or whatever)....and wait for the next round
    of orders.

    NOTE: The Ninja DOM tracks PnL based on FIFO, last price, etc. but I have not found a way to make it only track avg cost based on multiple entries. It insists of reseting the cost based on where orders got taken out.
    While the PnL calc is useful for tracking where my account is at any given time, it does not give me a simple average cost based purely on entry.

    Thanks.............

    #2
    Hello photog53,

    1. This information is not available programatically. It's only available from strategy generated orders.

    2. This is also only available within a strategy context for strategy-placed orders.

    Unfortunately NinjaScript does not provide an interface for accessing these details for manually placed orders.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hmmm.... (I was afraid that would be the answer).

      Thanks for answering back.

      P.S. It would be very nice if the Ninja DOM had a checkbox option (like FIFO) that simply calculated the average cost of all orders entered, and highlighted that price on the DOM.

      Comment


        #4
        Thanks for the suggestion photog53, we will add it to our list of feedback received.
        BertrandNinjaTrader Customer Service

        Comment


          #5
          havent tested it, but Accout.Positions gives the PositionCollection. from there one can scrap the avg price of each instument, they may be sent via charttrader/strategy/strategies.

          but dont think Account can be accessed via an indicator. one has to use an strategy.

          again havent tested it, so my apologies in advance if i am wrong.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by AveryFlynn, Today, 04:57 AM
          0 responses
          4 views
          0 likes
          Last Post AveryFlynn  
          Started by RubenCazorla, 08-30-2022, 06:36 AM
          3 responses
          77 views
          0 likes
          Last Post PaulMohn  
          Started by f.saeidi, Yesterday, 12:14 PM
          9 responses
          23 views
          0 likes
          Last Post f.saeidi  
          Started by Tim-c, Today, 03:54 AM
          0 responses
          3 views
          0 likes
          Last Post Tim-c
          by Tim-c
           
          Started by FrancisMorro, Today, 03:24 AM
          0 responses
          5 views
          0 likes
          Last Post FrancisMorro  
          Working...
          X