How to calculate AVERAGE PRICE in this EXAMPLE please?

 

Guys... i have a strategy... but i need to understand how to calcular the AVERAGE PRICE... can you help me?

For exemple below all are BUY ORDERS, ok?

LOTS      PRICE

0,01      1.01850

0.01      1.01800

0.02      1.01750

0.02      1.01700

0.03      1.01650

I would like to understand how I calculate how many pips my last order should make a pullback for me to get to BREAKEVEN.

Thanks

 
phantoxe:

Guys... i have a strategy... but i need to understand how to calcular the AVERAGE PRICE... can you help me?

For exemple below all are BUY ORDERS, ok?

LOTS      PRICE

0,01      1.01850

0.01      1.01800

0.02      1.01750

0.02      1.01700

0.03      1.01650

I would like to understand how I calculate how many pips my last order should make a pullback for me to get to BREAKEVEN.

Thanks

if you have n positions
avg = { sum(position(i).price x position(i).lote) for i from 1 to n } / { sum(position(i).lote)  for i from 1 to n }

if that is not clear, try reading that.
https://www.indeed.com/career-advice/career-development/how-to-calculate-weighted-average

How To Calculate Weighted Average in 3 Steps (with Example) | Indeed.com
How To Calculate Weighted Average in 3 Steps (with Example) | Indeed.com
  • www.indeed.com
Learn about a weighted average, how it's calculated and used and why it's important to know.
 

Forum on trading, automated trading systems and testing trading strategies

Any great idea about HEDGING positions welcome here

Fernando Carreiro, 2018.09.17 21:17

For those of you that want to learn to see the "light" and not fall into the trap of "hedging" and Grid strategies, here is the basic math:

How to Calculate the Net Resulting Equivalent Order:


Learn to do your research properly! Do not be blinded by false promises. Do the math!

Forum on trading, automated trading systems and testing trading strategies

calculate tp for a basket of positions

Fernando Carreiro, 2022.04.17 18:44

There is no exact MQL code to give you, because it varies depending on the strategy and what information needs to be calculated. That is why I gave you the math instead for you to implement depending on your requirements.

The math is self explanatory, but if you are having difficulty with it, then I doubt you will be able to implement it in code, but here are the variables anyway:

  • vi = volume of individual position
  • oi = open price of individual position
  • ci = close price of individual position
  • Vn = total volume for a basket of positions
  • On = net mean open price for a basket of positions
  • Cn = net mean close price for a basket of positions
  • PLn = profit/loss for a basket of positions
The rest is in the math calculations.


     
    Guys... when i am calculating the AVERAGE PRICE... i need put together SPREAD value to each order?
     
    phantoxe #:
    Guys... when i am calculating the AVERAGE PRICE... i need put together SPREAD value to each order?
    no need to use spread for calculating an average price
     
    phantoxe #: Guys... when i am calculating the AVERAGE PRICE... i need put together SPREAD value to each order?

    Spread is irrelevant when calculating the net average price of positions that are in the same direction.

    Even when dealing with positions in both directions on the same symbol, it is only of relevance when considering any floating closing prices, not yet established, but not pre-defined stops prices.

     
    phantoxe:

    Guys... i have a strategy... but i need to understand how to calcular the AVERAGE PRICE... can you help me?

    For exemple below all are BUY ORDERS, ok?

    LOTS      PRICE

    0,01      1.01850

    0.01      1.01800

    0.02      1.01750

    0.02      1.01700

    0.03      1.01650

    I would like to understand how I calculate how many pips my last order should make a pullback for me to get to BREAKEVEN.

    Thanks

    It is easy to put them into an array and use the standard MathMean function.

    Regarding your point about calculating how many pips for your last order to get breakeven, you need more info, like the profit/loss of the positions so you know what you are aiming for.


    #include <Math\Stat\Stat.mqh>
    //+------------------------------------------------------------------+
    //| Script program start function                                    |
    //+------------------------------------------------------------------+
    void OnStart()
      {
       double priceArray[] = {1.01850, 1.01800, 1.01750, 1.01700, 1.01650};
       
       ArrayPrint(priceArray);
       PrintFormat("Ave = %.4f", MathMean(priceArray));
       
    
      }
    //+------------------------------------------------------------------+
    

    Output:

    2022.08.11 23:08:18.904 1.01850 1.01800 1.01750 1.01700 1.01650

    2022.08.11 23:08:18.905 Ave = 1.0175


     
    on a side note that is an modified fibonacci strategy... wich is something like martingale but more gentle to your account (1,1,2,3,5,8, etc.). i hope you use that on an demo account, that 50 points fibonacci grid would burn your account very fast. also there are some martingale and grid EAs in these forums for free to try out and backtest. please be carefull
     
    R4tna C #: It is easy to put them into an array and use the standard MathMean function.Regarding your point about calculating how many pips for your last order to get breakeven, you need more info, like the profit/loss of the positions so you know what you are aiming for.
    No, you can't just use a normal average on the prices of positions to get the net mean price. You have to consider their volume as well. Please look at my post again ...
     
    Fernando Carreiro #:
    No, you can't just use a normal average on the prices of positions to get the net mean price. You have to consider their volume as well. Please look at my post again ...

    Thanks - I shall look into that further

     
    But how to calculate TP average price for a bunch of orders. But not for a break even , but to place TP for all orders in the same place in such way to have a desired profit.