'How can I open a trade when the price touches the line?

I'm trying to give an entry whenever the background is green (TrendDirection == 1) and the price hits the purple line (pacU).

Sample Long Position

I've tried this to give me a signal whenever the lowest level of the candle is less than the line but it doesn't give me any signals.

haLow   = request.security(ticker.heikinashi(syminfo.tickerid), timeframe.period, low)

pacU = ta.ema(haHigh, HiLoLen)

longCondition = false

if(TrendDirection == 1 and ta.crossunder(haLow, pacU))
    longCondition = true

if (longCondition)
    strategy.entry("long", strategy.long, 100)   
    


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source