The EMA is correctly calculated by both instances, but the instance based on data1 does not produce correct paintbar bar marking results. This becomes an issue because in the ultimate application for this concept there are nearly 1500 lines of calculations all but 8 of which--the paintbar calcs--are based on data1. I'd like to avoid having to modify tons of code if there is a way to get the tiny piece that references data2 to work as I had expected it would.
Here's the test code:
I've attached the simple workspace. If anybody has any ideas I'd appreciate hearing them!{******************************************************************************
Name : $Test_1
Description : Indicator that plots an ma and marks cons bars
Last Modified Date : 12/24/2018 --
******************************************************************************}
inputs:
MA_Length (89),
MA_Color (yellow),
Cons_Bar_Color (cyan);
variables:
MA (0, data1),
intrabarpersist Bar_Range (0.8, data2),
intrabarpersist Bar_Tail (0, data2),
intrabarpersist Body_Size (0, data2),
intrabarpersist Bar_Close ("", data2),
intrabarpersist Bar_Type ("", data2);
{******************************************************************************
perform ma calculation and plot
******************************************************************************}
MA = XAverage(close, MA_Length) data1;
Plot3(MA, "MA", MA_Color);
{******************************************************************************
paintbar calculations done at the close of the 8 point bar
*******************************************************************************}
if barstatus(2) = 2 then begin
if close data2 < open data2 then Bar_Close = "Bear"
else Bar_Close = "Bull";
Bar_Tail = Bar_Range - absvalue(open - close) data2;
if close data2 = open data2 then begin
if close data2 > low data2 then Bar_Close = "Bull"
else Bar_Close = "Bear";
end;
Body_Size = absvalue(open - close) data2;
if (Bar_Tail >= 0.5) or ((Bar_Tail = 0.4) and (Bar_Close <> Bar_Close[1]))
then Bar_Type = "Cons_Bar" else Bar_Type = "";
if Bar_Type = "Cons_Bar" then
PlotPaintBar(open data2, close data2, "Cons", Cons_Bar_Color);
end;
Thanks (and Merry Christmas / Happy Holidays)!
-pdq