How to calculate the totals profits of trading day ?
Thank you in advance for your help
- High Low indicator set
- Who can help for this?
- Trying to calculate total profit for trades
lucone wrote >>
How to calculate the totals profits of trading day ? Thank you in advance for your help
How to calculate the totals profits of trading day ? Thank you in advance for your help
I used the following code:
double CalculateDayProfits()
{
double TotalDayProfits;
double CurrentProfits = AccountProfit();
double FixedProfits = 0;
string DateToday = StringSubstr(TimeToStr(TimeLocal()),0,10); //format "hhhh.mm.dd"
string DateCloseOrder;
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
if (OrderSelect(i, SELECT_BY_POS,MODE_HISTORY)==true)
{
DateCloseOrder =StringSubstr(TimeToStr(OrderCloseTime()),0,10); //format "hhhh.mm.dd"
if (DateCloseOrder == DateToday)
{
FixedProfits+=(OrderProfit());
}
TotalDayProfits=FixedProfits+CurrentProfits;
}
return(TotalDayProfits);
}
double TotalDayProfits;
double CurrentProfits = AccountProfit();
double FixedProfits = 0;
string DateToday = StringSubstr(TimeToStr(TimeLocal()),0,10); //format "hhhh.mm.dd"
string DateCloseOrder;
int i,hstTotal=OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
if (OrderSelect(i, SELECT_BY_POS,MODE_HISTORY)==true)
{
DateCloseOrder =StringSubstr(TimeToStr(OrderCloseTime()),0,10); //format "hhhh.mm.dd"
if (DateCloseOrder == DateToday)
{
FixedProfits+=(OrderProfit());
}
TotalDayProfits=FixedProfits+CurrentProfits;
}
return(TotalDayProfits);
}

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register