you can try to calculate the money you will take of profits.
here is the formula
lots * tickvalue * point = xx currency
write your code on method onTick or onTimer to monitor you floting profits you will figureit out. instead of calcualte point
and for better coding habits you probably need to change this style code
for(int i = OrdersTotal() - 1; i >= 0; i--) { double orderopenprice = OrderOpenPrice(); int orderticket = OrderTicket(); int ordertype = OrderType(); double orderlots = OrderLots(); ... }
to this
double orderopenprice; int orderticket; int ordertype; double orderlots; for(int i = OrdersTotal() - 1; i >= 0; i--) { orderopenprice = OrderOpenPrice(); orderticket = OrderTicket(); ordertype = OrderType(); orderlots = OrderLots(); }
do not including var into loop body
GOOD LUCK
BuyAveragePrice = NormalizeDouble((buyersum - sellersum) / (buyerlots - sellerlots), Digits); Print("buy avg is"+BuyAveragePrice+"");
Average Buy price has nothing to do with Sell orders. Your formula is bogus.
It is Lots Weighted Average Price (∑ opi × loti ÷ ∑ loti) This is the break even price of all orders combined.
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
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello All coders.
Have a nice day.
I tried to create buy and sell common takeprofit point by this codes.
It work at first well but when orders open so much its added order lot sizes are huge and take profit point are more away than actual profit point.
This mean All buy orders are in profit condition but codes are still run for takeprofit point .
So next opposit orders are more open and more take profit points away.
LATER Account balance cannot tolerate float and wipe out.
Please help me more reasonable takeprofit codes for buy and sell orders or suggest me.