Trendline to end at one bar before

 

I am using these 2 indicators.

trendplotter.mq4
http://www.forexfactory.com/showthread.php?t=46668&page=6

TrendLine Alert.mq4
http://www.trade2win.com/boards/trading-software/148012-trendline-alert-indicator-mt4.html


There is a slight problem with the combination of these two.

When a position is closed, the trendplotter will draw a trendline ending where the position was closed.

Since the price can usually move above and below this point, the TrendlineAlert will trigger multiple times until the next candle is drawn.


To fix that I am trying to edit the TrendlineAlert indicator so that the trendline will end one candlestick before the said position. That way the price will not hit the trendline and will not trigger the alert.

ObjectCreate(label, OBJ_TREND, 0, t1, p1, t2, p2)

What can I add to t2 so that the trenline will end 1 bar before t2?

Or is there another way to go around this?

 
  1. Please use the link button (control-K.) Use the link button See the difference: http://www.forexfactory.com/showthread.php?t=46668&page=6
  2. Moving the endpoint will change nothing. The alert code is designed to alert everytime the market moves further above/below the trendline (as extended to the future,) or Hline. It does not stop at a new candle.
  3. If you want something different you'll have to code it.