I would like to calculate the weighted average over an array.
Something like WAverageArray. But that does not exist.
Code: Select all
Arrays:// Position profit array
Intrabarpersist Openposition_exit_array[](0);
If close <> close[1] then begin
Profit_count_exit = Profit_count_exit + 1;
end;
// expand the array by one
array_setmaxindex(Openposition_exit_array, profit_count_exit);
// post data to array
Openposition_exit_array[Profit_count_exit] = openpositionprofit;
// calculate the profit values
Profit_amt = Openposition_exit_array[profit_count_exit];
Highest_Profit_amt = Highestarray(Openposition_exit_array, profit_count_exit);
Average_profit_amt = AverageArray(Openposition_exit_array, profit_count_exit);
W_Average_profit_amt = WAverage(Profit_amt,profit_count_exit);
Is there someone who has the method for calculating the Weighted Average of an array?