[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Odd calculation problem



PureBytes Links

Trading Reference Links

Here's a strange one.  I've got a chart with 2 data series:  NQ1H and 
NDX.  I created an indicator to display the spread between NQ1H and 
NDX.  

  plot1(           (h+l)/2 - (h data2 + l data2)/2    , "spread");
  plot2( xaverage( (h+l)/2 - (h data2 + l data2)/2 ,5), "xavg");

So plot1 is the difference between the midrange of NQ1H (data1) and 
the midrange of NDX (data2).  This plots fine.

plot2 shows the recent average value.  Notice it's identical to plot1 
(cut and pasted), with an "xaverage" wrapped around it.

It plots zero.

In fact if I wrap the spread calc in ANY function, it plots zero.  If 
I just display the spread calc, or any calculation involving that 
spread value but not requiring a function, it works fine.  Add in a 
function and it's zero.

Any guesses?  It must be some bizarre multi-data weirdity but I 
haven't figured it out.  I'm even more confused because I've done 
almost an identical indicator before, and it works just fine.  What 
am I missing in this code??

Gary