Download MetaTrader 5

Trendline to end at one bar before

To add comments, please log in or register

I am using these 2 indicators.


TrendLine Alert.mq4

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:
  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.
To add comments, please log in or register