Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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)   
    

>Solution :

You need to use the := operator when you assign a new value to a variable.

So, it should be longCondition := true

Kolay gelsin.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading