• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 6:39am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 6:39am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Multiple pending orders with multiple take profit ea 5 replies

Counting Multiple Orders With Multiple Magic Numbers in one EA 6 replies

How to calculate highest or lowest value from multiple arrays? 4 replies

Open Multiple Orders On Multiple Pairs On One Chosen Cross 1 reply

Easy way to calculate position sizes? 3 replies

  • Platform Tech
  • /
  • Reply to Thread
  • Subscribe
Tags: How To Calculate Position Prices of Multiple Orders ?
Cancel

How To Calculate Position Prices of Multiple Orders ?

  • Post #1
  • Quote
  • First Post: Aug 9, 2011 4:28am Aug 9, 2011 4:28am
  •  yster
  • | Joined Nov 2005 | Status: Member | 31 Posts
Hi all,


let's say, i made multiple transactions below:

Buy 500,000 AUDUSD at 1.03756
Buy 500,000 AUDUSD at 1.03726
Buy 1,000,000 AUDUSD at 1.03856
Buy 500,000 AUDUSD at 1.02362
Buy 100,000 AUDUSD at 1.00192


My total position is now: 2,600,000 . How can i calculate what average price for this position. what formula can i use?


Thanks
  • Post #2
  • Quote
  • Last Post: Aug 9, 2011 5:02am Aug 9, 2011 5:02am
  •  FinGeR
  • | Joined Nov 2005 | Status: Member | 38 Posts
Inserted Code
double PriceAverage() 
{ 
   double PriceSum=0;
   int count=0;
   for (int i=0; i<OrdersTotal(); i++) 
      { 
         if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) 
         if((OrderSymbol()==Symbol()) ) 
            {
              if(OrderType()==OP_BUY || OrderType()==OP_SELL) PriceSum+=OrderOpenPrice();
              count++;
                        
            }
      } 
   if(PriceSum<1) return(0); 
   
   return(NormalizeDouble(PriceSum/count,Digits)); 
}

Inserted Code
int start()
  {
Print(Symbol()+"= "+PriceAverage()); 
}
 
 
  • Platform Tech
  • /
  • How To Calculate Position Prices of Multiple Orders ?
  • Reply to Thread
0 traders viewing now
Top of Page
  • Facebook
  • X
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • X

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2023