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

Strategy's Average Position Price Per Direction

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

    Strategy's Average Position Price Per Direction

    Hi, whats the simplest way to find Strategy's Average Position Price Per Direction (Long or Short) or per signal. I have a strategy that executes long and short orders are are supposed to be handled separately (2 signals, long and short) so at all times need to know the overall long positions average price and overall short positions average price... Thanks

    #2
    Hello shahabjet1,

    Thanks for your post.

    You can access Position.AveragePrice for the current position's average entry price.

    Reference: https://ninjatrader.com/support/help...erageprice.htm
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hi; that's for the response but I do not think you are properly answering my question. I need your help. I have a strategy that opens multiple long orders and short orders at same time on same index. The long orders will be managed as a group and the short orders also need to get managed as a separate group. So Strategy at any time need to keep track of each basket of trades (long and short, different signals) separately. Makes sense what I am saying? So what I need is to be able to keep track of average price for each basket (long and short) as I add positions to each basket. Need a simple way to keep track of each baskets average price, as I add trades to each basket... Can I get a detailed and proper response for this please? Will be a huge help. Or a sample code will be great. You response above to use Position.AveragePrice does NOT work cause both long and short basket of trades are on same index so the overall average is useless. I need average per long and short trades....

      Comment


        #4
        Hello shahabjet1,

        Thanks for your reply.

        There is a fundamental misunderstanding. You cannot be both long and short in the same strategy, on the same instrument on the same account.

        You would need to run two instances of your strategy using two separate accounts in order to be both long and short at the same time on the same instrument.

        You may want to review this forum topic: https://ninjatrader.com/support/foru...act#post792660

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Thanks, I understand how my request may confuse you. Obviously the account gets combined by both trades, but the strategies still need to keep track of each basket individually, which is completely possible. As a matter of fact, currently I am having 2 different strategies running at same time, one for short and one for long, to your point. But I want to combine them together and have one strategy that combines both but keep track of each basket separately. So I just need a way to track average long and short positions price in basket...

          Comment


            #6
            I think I just need a sample code that open simple orders with any criteria on any instrument and then once each order is executed the strategy stores the execution price in a list and keep doing that for all future orders. That's what I need to learn to code, can you please provide an example code?

            Comment


              #7
              Hello shahabjet1,

              Thanks for your reply.

              Are you asking to know the averagePrice of the existing positions is or are you asking to know what the average price of all positions (open and closed) (in the same direction ) is and if so, since when?
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                Well my biggest issue is learn how to code to capture the price of executed orders (execution price) and store them in a list or some other variable. That way I can add them up and divide by position count. Can you please provide a simple code that shows me how to capture and store execution prices?

                Comment


                  #9
                  Hello shahabjet1,

                  Thanks for your reply.

                  The current Position.AveragePrice will provide the average entry price of the current position.
                  Reference: https://ninjatrader.com/support/help...erageprice.htm

                  Regardless, I have attached a simple example of obtaining each entry price and putting it in a list and then printing that list.

                  AveragePriceList.zip
                  Paul H.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by DJ888, 04-16-2024, 06:09 PM
                  4 responses
                  12 views
                  0 likes
                  Last Post DJ888
                  by DJ888
                   
                  Started by terofs, Today, 04:18 PM
                  0 responses
                  8 views
                  0 likes
                  Last Post terofs
                  by terofs
                   
                  Started by nandhumca, Today, 03:41 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post nandhumca  
                  Started by The_Sec, Today, 03:37 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post The_Sec
                  by The_Sec
                   
                  Started by GwFutures1988, Today, 02:48 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Working...
                  X