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),
intrabarpersist PxRef1(0),
intrabarpersist BidData(0),
intrabarpersist AskData(0);
inputs: MovAvgLength(360);
BidData = close of data2;
AskData = close of data3;
PxRef = average((BidData + AskData) / 2, MovAvgLength);
PxRef1 = average((close of data2 + close of data3) / 2, MovAvgLength);
plot1(PxRef);
plot2(PxRef1);
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.