# counting max achievable profit

Do you want to write a trading robot? Find solution in MQL5 Reference!
359
2014.10.01 08:32

Hi guys, I´m building one EA based on MA crosses. This EA uses trailing stops. I want to find out values that would cause profit in majority of cases. I was wondering if we can calculate somehow "max achievable profit" If I open a trade just after 2 MA crosses, what is the max profit I can reach. I would need these values, their average value, modus and median. It can be displayed in chart or in xls file.

Any ideas? thanks

17919
2014.10.01 12:56
As a rule, ZigZag indicator is used to calculate maximal possible profit. Just take extremums inside your crossings.
Moderator
30736
2014.10.01 19:41
marketeer:
As a rule, ZigZag indicator is used to calculate maximal possible profit. Just take extremums inside your crossings.

Why do you need ZigZag for that ? Just calculate the maximum/minimum between 2 crosses.

Something like :

```double getMaximum(datetime firstCross,datetime secondCross)
{
double high[];

if(CopyHigh(_Symbol,_Period,firstCross,seconCross,high)!=-1)
{
int index=ArrayMaximum(high);
if(index!=-1)
return(high[index]);
}
return(-1);
}
```
359
2014.10.01 20:33
Thank you!
17919
2014.10.01 21:12
angevoyageur:

Why do you need ZigZag for that ? Just calculate the maximum/minimum between 2 crosses.

Something like :

What your code is supposed to return? Highest high between 2 crosses? This is far from the potential profit inbetween, marked on the screenshot.

ZigZag is a well-known tool for potential profit measurement - this is not my personal invention.

Moderator
30736
2014.10.01 21:41
marketeer:

What your code is supposed to return? Highest high between 2 crosses? This is far from the potential profit inbetween, marked on the screenshot.

Really ? Why ?

ZigZag is a well-known tool for potential profit measurement - this is not my personal invention.

Then you can maybe explain how.