I have written a very basic indicator that calculates the midprice as the average of the bid (data2) and ask price (data3). it then calculates the simple moving average. See code:
Code: Select all
vars: intrabarpersist PxRef(0),
BidData = close of data2;
AskData = close of data3;
PxRef = average((BidData + AskData) / 2, MovAvgLength);
PxRef1 = average((close of data2 + close of data3) / 2, MovAvgLength);
The result i get shows 2 moving average lines (red and blue) which are different to each other (see attachment).
My question is why is PxRef different to PxRef1 and which method is the correct method.
p.s. i did try remove the intrabarpersist to all variable and still received the same result.
Thanks for the Help.