Just curious if anyone else has seen this. I wanted to use the average price for my BuyPrice. I tried this formula first but it wouldn't calculate properly:
Then I just made a small change and put Open last in my calculation and then the calculation would come out correctly:
AveragePrice=(High + Low + Close + Open)/4;//doesn't work right if you put open first in equation
BuyPrice = SellPrice = ShortPrice = CoverPrice = AveragePrice;
Does anyone have any idea why that might be? It shouldn't make any difference what order you put the four prices in the calculation but it does.
Hi @Marcel. I have used that code in my templates for years and never had a problem with it. Send me email directly if you want me to help you investigate the issue.
AveragePrice1 = ( Open + High + Low + Close ) / 4;
_TRACE( "Average 1 = " + LastValue(AveragePrice1) );
AveragePrice2 = ( High + Low + Close + Open ) / 4; //doesn't work right if you put open first in equation
_TRACE( "Average 2 = " + LastValue(AveragePrice2) );
AveragePrice1 = ( Open + High + Low + Close ) / 4;
_TRACE( "Average 1 = " + Ref(AveragePrice1, -1) );
AveragePrice2 = ( High + Low + Close + Open ) / 4; //doesn't work right if you put open first in equation
_TRACE( "Average 2 = " + Ref(AveragePrice2, -1) );
AveragePrice1 = ( Open + High + Low + Close ) / 4;
_TRACE( "Average 1 = " + Ref(AveragePrice1, -2) );
AveragePrice2 = ( High + Low + Close + Open ) / 4; //doesn't work right if you put open first in equation
_TRACE( "Average 2 = " + Ref(AveragePrice2, -2) );
(tested both 6.10 32-bit - 6.28.0 64-bit - I checked also )
As a side note, in any AmiBroker formulas it is also possible to use "Avg" (similar to Close, Open, etc.- but there is no abbreviation) to represent an average price array.
It is calculated as (High+Low+Close)/3 - corresponding to the so called "typical price" as defined in other trading applications.