What I then do is to make all the outcome an positive number. So if the openinggap was -0,40. I multiple this with -1 to get 0,40. I got this to work.
But now I want to calculate the average of all the opening gaps. This to determine the risk involved when I have a strategy that will go overnight.
I tried to use AverageArray, but it is not working.
Code: Select all
Count = count;
if date <> date then begin
open_gap[count] = opend(0);
close_gap[count] = closed(1);
Openingsgap = open_gap[count] - close_gap[count];
if openingsgap < 0 then
openingsgap = (open_gap[count] - close_gap[count])*-1;
avg_gap[count] = (opend(0) - closed(1));
averagegap = averagearray(avg_gap, count);
Print("Date: ",formatdate("dd-MM-yyyy ",eldatetodatetime(date))," open ", open_gap[count]," Close Yesterday ", close_gap[count]," openingsgap ", Openingsgap," average", Averagegap);
Can someone give me a hint?