breakeven calculate

 

how to calculate the distance so that two or more open trades reach a breakeven.

 

here is one example:

void OnTick(){
   double sumProfits=0;
   bool checked=false;
   
   for (int pos=0;pos<OrdersTotal();pos++){
      if (!OrderSelect(pos,SELECT_BY_POS)) continue;
      if (OrderType()>=2) continue;
      sumProfits +=OrderProfit();
      if (!checked) checked=true;
   }  
   
   if (NormalizeDouble(sumProfits,0)==0 && checked) Alert("Breakeven reached");   
}


 
javiervillagran96: how to calculate the distance so that two or more open trades reach a breakeven.

Break even price = Lots weighted average price.
          OrderOpenPrice question . - MQL4 programming forum
          looking for sample code on how to calculate the price BE for a few Buy and Sell orders simultaneously - Pips - MQL4 programming forum