Code to calculate the profit being made in trades
You just need to check the order symbol at the same time you check the magic so...
if(OrderMagicNumber() == getMagic() && OrderSymbol() == Symbol())
Lux
Thank you very much Lux!
You just need to check the order symbol at the same time you check the magic so...
if(OrderMagicNumber() == getMagic() && OrderSymbol() == Symbol())
Lux
Thank you very much Lux!
You agree to website policy and terms of use
The following code appears to correctly report the profit being made in trades across all pairs trading on one account. But I need it to report specifically on the currency pair it is trading in. Could someone kindly amend the code to achieve this. Thanks
double profitCount()
{
double oc = 0;
for(int cnt = 0 ;cnt<OrdersTotal();cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderMagicNumber() == getMagic())
{
oc+= OrderProfit()+OrderSwap()+OrderCommission();
}
}
return(oc);
}