The picture below is the last several rows that the indicator produced. These are correct and match the chart plot. The picture below is the last several rows that the signal produced. These do not match the chart plot. I've attached a workspace with two charts: 1) one data stream [5-min] and 2) three data streams [3R, 8R, and 5-min]. Here is the three data stream code stripped down to minimum:
Code: Select all
{*************************************************************************************
Name : $test_MA signal
Description : test MA signal calcs on a 3 data stream chart
Last Modified Date : 11/02/2018
*************************************************************************************}
{************************************************************************************
variable initialization section
*************************************************************************************}
inputs:
MA_Length (20);
variables:
intrabarpersist MA (0, data3);
{*************************************************************************************
5-min MA calculations
*************************************************************************************}
if barstatus(3) = 2 then begin
MA = XAverage(close data3, MA_Length);
end;
{*************************************************************************************
diagnostic print section
*************************************************************************************}
once ClearPrintLog;
if barstatus(3) = 2 then begin
print("MA",
" 5-min bar= ", barnumber data3 + MaxBarsBack:5:0,
" close data3= ", close data3:6:1,
" MA= ", MA:7:2,
" MA[1]= ", MA[1]:7:2,
" MA[2]= ", MA[2]:7:2,
" MA[3]= ", MA[3]:7:2
);
end;
Code: Select all
{*************************************************************************************
Name : $test_MA
Description : test MA signal calcs on a single data stream chart
Last Modified Date : 11/02/2018
*************************************************************************************}
{*************************************************************************************
variable initialization section
*************************************************************************************}
inputs:
MA_Length (20);
variables:
intrabarpersist MA (0);
{************************************************************************************
5-min MA calculations
************************************************************************************}
MA = XAverage(close, MA_Length);
{************************************************************************************
diagnostic print section
************************************************************************************}
once ClearPrintLog;
print("MA",
" 5-min bar= ", barnumber data1 + MaxBarsBack:5:0,
" close data1= ", close data1:6:1,
" MA= ", MA:7:2,
" MA[1]= ", MA[1]:7:2,
" MA[2]= ", MA[2]:7:2,
" MA[3]= ", MA[3]:7:2
);