Average Deviation MQL4 code help

 

Hello

I create trading ideas in Excel and then write an EA based on these rules. I am stuck however with Average Deviation. This yields different results than Standard Deviation but I do not know how to write it.

Here is an example of the Excel code and I would be very grateful if someone can provide the respective MQL code for insertion into an EA.

=AVEDEV(F1:H6)+G6

This is the formula of the Average Deviation of the last 6 period high,low and close PLUS the previous low.

Part of an entry will then be ;

&& AveDev1 < Close[1]...... etc

I hope someone can help.


Regards

 
It might help you explained what AVEDEV does in Excel . . . or do you expect someone else to go and Google it ?
 

OK.

Average Deviation is the average of all the distances between the group average and each data point within that group. They are absolute values ...therfore positive values.

The Average Deviation of 1,2,3,4,5,6,7 is 1.71427

The average (mean[m]) of 1,2,3,4,5,6,7 is 4. We then subtract all the numbers from the mean and make the result positive ...eg 1-4 is actually -3 but we will make this 3.

1-4=3, 2-4=2, 3-4=1, 4-4=0, 5-4=1, 6-4=2, 7=4=3.

Adding these together ; 3+2+1+0+1+2+3 = 12 and the average of these is 12 divided by 7 (there are seven numbers) is

1.71427.


I am lookinf for a way to code this in mql hopefully without coding each part.

thanks.

Reason: