Hi
This is the first time I have had to ask a question on the forum, but I am having huge problems.
I have previously coded some rather complex indicators but this one has me stumped. I am sure it is something I am doing wrong but I can't see it.
I am accumulating all the Positive and Negative closed orders in the history. The positives work correctly - I have checked. But the negatives are not right.
The code is;
if(OrdProfit > 0.0)
{
OrdProf ++ ;
TotalProf += OrdProfit;
}
else
{
OrdLoss ++ ;
TotalLoss += OrdProfit;
Alert("Cnt "+string(OrdLoss)+" Prof "+DoubleToString(OrdProfit,2)+" Tot "+DoubleToString(TotalLoss,2));
}
The results from the Alert (which is temporary) are, for example;
Cnt 4 ----
Cnt 3 Prof -773.55 Tot -93.80
Cnt 2 Prof -237.66 Tot 867.55
Cnt 1 ----
You can see that sometimes it adds, and then sometimes it subtracts.
I have tried adding, subtracting, testing for negative, Squaring then taking Sqrt etc - all with no success. I have even re-installed the platform to a new folder.
I would appreciate any help if it is possible. Many Thanks
This is the first time I have had to ask a question on the forum, but I am having huge problems.
I have previously coded some rather complex indicators but this one has me stumped. I am sure it is something I am doing wrong but I can't see it.
I am accumulating all the Positive and Negative closed orders in the history. The positives work correctly - I have checked. But the negatives are not right.
The code is;
if(OrdProfit > 0.0)
{
OrdProf ++ ;
TotalProf += OrdProfit;
}
else
{
OrdLoss ++ ;
TotalLoss += OrdProfit;
Alert("Cnt "+string(OrdLoss)+" Prof "+DoubleToString(OrdProfit,2)+" Tot "+DoubleToString(TotalLoss,2));
}
The results from the Alert (which is temporary) are, for example;
Cnt 4 ----
Cnt 3 Prof -773.55 Tot -93.80
Cnt 2 Prof -237.66 Tot 867.55
Cnt 1 ----
You can see that sometimes it adds, and then sometimes it subtracts.
I have tried adding, subtracting, testing for negative, Squaring then taking Sqrt etc - all with no success. I have even re-installed the platform to a new folder.
I would appreciate any help if it is possible. Many Thanks