Download MetaTrader 5
To add comments, please log in or register
Make profit on MQL5 services. It's easy!
David
47
David 2016.07.03 15:42 

hi all

I'm looking for sample code,  or an explanation, on how to calculate the price Break Even for a few Buy and Sell orders simultaneously

 

basically this is the scenario

1 Sell order of 1 lot, 1 Buy order 50 pip above the sell order of 1,5 lots at which level i will Reach the break even? 

keep in mind that i could have multiple sell order and multiple buy orders... 

any idea? 

whroeder1
13641
whroeder1 2016.07.03 17:52  
didjeridoo: 1 Sell order of 1 lot, 1 Buy order 50 pip above the sell order of 1,5 lots at which level i will Reach the break even?
  1. Volume weighted average price. Sum[ OrderLots * (OrderType == OP_BUY ? +1 : -1) * OrderOpenPrice ] / Sum[ OrderLots * (OrderType == OP_BUY ? +1 : -1) ] if denominator is zero, no solution, e.g. buy 1 sell 1, hedging, any price.
  2. BEprice = [1 * (-1) * 1.2345 + 1.5 * (+1) * 1.2395] / [1 *(-1) + 1.5 * (+1)] = 0.62475 / 0.5 = 1.2495.
    profit= -1* DeltaPerlot * (1.2495-1.2345) + 1.5 * DeltaPerlot * (1.2495-1.2395) = DeltaPerlot *[ -1 * 0.0150 + 1.5 * 0.0100 ] = DeltaPerlot * [ -0.015 + 0.015 ] = 0
/
To add comments, please log in or register