I'm plotting the LowPass filter over price and identifying peaks and valleys visually using dots with plotGraph.

As per the valley() and peak() formulas, the dots are appearing one bar ahead (to the right) of the actual valley or peak.

I'm not sure what to set the y parameter in plotGraph to, in order to have to dots appearing at the actual valley or peak bar. When I set it to myseries[0], although dots display, the price and LowPass series lines disappear, and too many dots appear, same as if I try to get in the ballpark by using priceHigh(1) or priceLow(1).

Code:
function indicatortest() {
 set(PLOTNOW);
 int ma_short = 5;	

 BarPeriod = 60*8;
 vars Price = series(price());
 vars lowpass_MA_short = series(LowPass(Price, ma_short));

 if (valley(lowpass_MA_short)) {
  plotGraph("valley", 1, lowpass_MA_short[0] ,DOT, YELLOW );
  //plot("valley", lowpass_MA_short, DOT, YELLOW );
 } 
  else if (peak(lowpass_MA_short)) {
   plotGraph("peak", 1, lowpass_MA_short[0], DOT, GREEN );
   //plot("peak", lowpass_MA_short, DOT, GREEN );
 }
}



The commented out code is the code that plots the dots according to the valley and peak functions, that is, 1 bar after the event took place.

The x position is 1, as in 1 bar period in the past, and the y position needs to be the y position of the actual peak or valley (multiplied by a small amount to get it hovering just above or below). How to get that value is eluding me.

Any comments or solutions would be appreciated.